#Modular graphs - transferring object variables?

1 messages · Page 1 of 1 (latest)

timid otter
#

Graph assets seem like they are meant to be modular. That is to say that I assume I'm meant to be able to store them in my project similarly to how I'd store any C# MonoBehaviour and anyone could grab one of my graphs and use it as a behaviour on their own objects. However, object variables aren't retained, you have to rebuild them on the new object. This is a pain even if you do have an original somewhere to copy the component from. Am I missing something? Of course I can share a GameObject already setup, that's not that intuitive though.

#

Wouldn't it be better if object variables and their types came with the graph? It's the only way to have per-instance values which is all I care about.

#

i want someone to be able to choose from a folder full of graphs that contain useful behaviours in my project.

#

like with monobehaviours the serialized member variables just come with the script cos duhhh

timid otter
#

Is there at least a way to provide info from within a graph asset so that when you add it to a ScriptMachine it populates the variables component automatically from some embedded data?

timid otter
#

Currently I'm just writing required object variables into the summary as a clue for anyone who uses the graph asset.

fathom ibex
timid otter
#

Thought so. I don't love it but it works. I was hoping there was just some hidden button I was failing to see lol

mortal sapphire
fathom ibex
#

No he is saying that when you have a Script Machine that is not Embed like the one in the picture where you can input the Script Graph, there is no way to tell the GameObject what Object variables to add automatically. Like if the graph expects a Object variable that is a Type of bool with a name of IsGrounded you will need to manually add it after adding the Graph to the Script Machine

#

But I do wish graphs had like a Definition tab in the Object Variables tab so that once it's added to a script machine those variables are forced so it automatically adds it to the Variables component and cannot be removed unless removed from the Definition

timid otter
#

Yeah, its like... imagine if C# somehow made you write serialized fields from scratch each time you add it to a gameObject. That'd be very weird.

#

Cant they merge variable component fields into scriptmachine?? ^^;

fathom ibex
#

Mmm I wonder if I can achieve something like this, Let me see

timid otter
#

Maybe as you're much closer to UVS than I, do you happen to know of any reason why they may have done it this way? I can't think of a good reason to have variables stored in a different place from the graph.

From my perspective at least, it's silly, a graph's get/set var nodes all reference strings for var names, the script literally won't work without the named variables present.

#

I can't think of a situation where i'd want to share a graph with someone, but have them decide on their own random stack of variables to go with my graph, instead of the ones i prescribe

fathom ibex
timid otter
#

hm, yeah. Your idea to store definitions in the graph sounds good, then the scriptMachine can take on the job of presenting the fields for them. Remove the need for the variables component altogether

fathom ibex
timid otter
#

ah yeah, you did say that

fathom ibex
#

Something like this, It's not working yet I just setup the subtab but you will have your normal Variables and the required ones will be added to any gameobject you add this asset to

#

and when you in a asset it will appear like this so by default you will add required variables

timid otter
#

that's beautiful

#

all your work is stuff this tool really really needs

fathom ibex
#

I was thinking something like this, It needs more testing. and I might need a better way to do it but so far this is a working example.

It will automatically add the Variables for you and you cannot remove them since they are In the required tab

fathom ibex
#

Yeah, so right now I cant get it to where it adds the variables for every script machine in the project to automatically, you would need to select the GameObject which will trigger the machines to add their required variables. Because i have no way of changing the Script Machine code had i had access to it i could have used OnEnable and OnUpdate to ensure they add the required variables

timid otter
#

Nice work man. Thats a perfectly ok caveat. Thanks for digging into it!

fathom ibex
# timid otter Nice work man. Thats a perfectly ok caveat. Thanks for digging into it!

If it's something you need or want to try I can send it to you.

But 2 things.

  1. is the problem i described of needing to make sure the object is selected so that the editors of the Script Machines can trigger the add.

  2. Since i cannot serialize the Required variables with the GraphAsset it's self i needed to make another Central asset that will do the serializing for all the assets, which might be a bit of a problem if you want to share it you would need to make sure the project has the new asset and is always updated when you add a new variable.

I really wish I could edit the actual files it's such a constraint to work around them

timid otter
#

needing to click on the object itself is fine. The additional asset is also fine, but the big thing with all community addons is that I don't 100% know if I can put them into practice at work. I'd need to figure out any quirks with our assetbundle pipeline and keeping devs in synch with our build team etc.

But for personal projects, hells yeah.

fathom ibex
# timid otter needing to click on the object itself is fine. The additional asset is also fine...

Oh ok I see, makes sense that you probably won't be able to use it in a work project.

It is a small import as it's not part of the Addons. I will probably send it tomorrow

Also thinking about it the problem is not that big because in order to add the Graph to the Script Machine you need to have the Object selected. The problem would only exist for Graphs that were already in a script machine before the Required variables were added but most likely it wont matter because those Graph/GameObjects will already have the Object variables that were needed or else the Graph would have been throwing errors

timid otter
#

Yeah exactly. Not a prpblem at all really. And the caveat is gentle enough

timid otter
#

Yes, plz do send. I will happily try it out and keep it on hand

#

I was wondering if modularizing add-ons could be on the cards at some point in future, through a sort of mod-manager of some kind.

#

To enable/disable certain modifications

fathom ibex
fathom ibex
timid otter
#

yeah, the add-ons

timid otter
#

absolutely not urgent or even necessary lol

fathom ibex
solar bough
#

I dont know if this is the same thing that was discussed here but when using prefabs with visual scripts on them, is there a way to have the object variable not be empty ?
For example i have a trigger that has the player's camera as an object variable, if i make the trigger a prefab and place it somehwere else, even in the exact same scene, the camera varaible is empty again and i need to put it back in there
is there a way to avoid that ? or am i doing things wrong ? this is kinda keeping me from using prefabs because a lot of stuff have many object variables, and its tedious to fill in for each one

fathom ibex
solar bough
#

I guess ill do that then, thank you

mortal sapphire
# solar bough I guess ill do that then, thank you

i had the same problem and yes i had to use a scene variable instead of an application or object/graph variable .

you must know what type of variable you must get for what you need essentially, only through time mostly you will learn in my experience