ArticyRef Object Handling - Type issue

Mon 29. Apr 2019, 21:19

Hi there, I'm trying to use Object Handling as defined in this tutorial https://www.nevigo.com/articy-importer/ ... ccessByRef but having some trouble.

In this first example I try to use a type constraint:
Code: Select all
using System.Collections;
using UnityEngine;
using Articy.Unity;

public class ArticyContent : MonoBehaviour
{
    [ArticyTypeConstraint(typeof(Character))]
    public ArticyRef articyModel;
}

But the type "Character" doesn't exist.

I get the same problem if I try to get type using the GetObject<type> syntax,

Code: Select all
var obj = myRef.GetObject<Character>();


I'm not sure where this Character class is supposed to be, or which classes are even available to reference. Ideally I'd like to find out how to get refs cast into FlowFragments. I'm on Unity 2018.3 with the plugin version 34886 2.0.3

Thanks in advance, loving the application so far! Just hoping the Unity integration can work for me.
User avatar
ryanmiller
 
Posts: 6
Joined: Mon 29. Apr 2019, 21:15
Location: Toronto, ON

Re: ArticyRef Object Handling - Type issue

Tue 30. Apr 2019, 15:37

Hi ryanmiller,

Its important to remember that all those examples only work with actual project data. In most of the help articles we therefore reference the "Maniac Manfred" demo project. Some other code examples use dummy data.
In this case it is difficult to explain the ArticyTypeConstraint without having any type (as in an empty project), as those types are generated from your articy:draft data. And your articy:draft project data widely differs from others.
So this makes writing and therefore understanding the documentation a bit difficult.
Just try to remember that if you see classes not part of the plugin, it usually means to use types and data from your project.

I'm not sure where this Character class is supposed to be, or which classes are even available to reference. Ideally I'd like to find out how to get refs cast into FlowFragments. I'm on Unity 2018.3 with the plugin version 34886 2.0.3

In this case its possible to constraint directly to FlowFragment, as each articy:draft object gets a corresponding type in the plugin.

Code: Select all
public class ArticyContent : MonoBehaviour
{
    [ArticyTypeConstraint(typeof(FlowFragment))]
    public ArticyRef articyModel;
}


Its also an important concept to understand that if you create a Template inside articy:draft for a type, it will get a corresponding class generated in the plugin. For example a template for entities, lets call it "Weapon". The plugin will generate a class Weapon for you deriving it from the C# class Entity which is part of the plugin, this allows you to use the type Weapon throughout your code. For example inside GetObject of your articyref.

Hope that clears it up, if you have any more questions let me know!

Best regards

Nico
Nico Probst
Senior Software Engineer | Articy | LinkedIn
User avatar
[Articy] Nico Probst
Articy Staff
Articy Staff
 
Posts: 217
Joined: Wed 23. Nov 2011, 09:45
Location: Bochum

Re: ArticyRef Object Handling - Type issue

Tue 30. Apr 2019, 15:51

Thanks Nico. The connection between Articy classes and C# Classes in Unity sounds pretty exciting and more powerful than I expected. Now I just need to get it working!

I tried the code example you provided with
Code: Select all
[ArticyTypeConstraint(typeof(FlowFragment))]
(and using Articy.Unity) and am still getting type errors mentioning it can't be found.

Shouldn't my project contain the FlowFragment type/class? That is a part of Articy itself. I am not using templates in my project as I don't see a need for them yet.
User avatar
ryanmiller
 
Posts: 6
Joined: Mon 29. Apr 2019, 21:15
Location: Toronto, ON

Re: ArticyRef Object Handling - Type issue

Tue 30. Apr 2019, 15:53

Oh, I think I found the issue. There's a project namespace in addition to the Articy.Unity namespace.

Will keep you updated...

[edit]

Yes, I think that was my issue! In this case, I added another using statement to include Articy.[theprojectname] and I've got access to everything I need now.

Thanks for the help!
User avatar
ryanmiller
 
Posts: 6
Joined: Mon 29. Apr 2019, 21:15
Location: Toronto, ON

Return to articy:draft Unity Importer

Who is online

Users browsing this forum: No registered users and 9 guests

Who We Are
Contact Us
Social Links