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.
#Modular graphs - transferring object variables?
1 messages · Page 1 of 1 (latest)
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
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?
Currently I'm just writing required object variables into the summary as a clue for anyone who uses the graph asset.
Well the only option right now would be to make a prefab with the Variables and the Asset attached and then add the Object to the scene and Unpack it or Just copy the variables component from it and paste it on the GameObject your added the Graph Asset to. But there is no automatic way to do it
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
are you saying you cannot copy a project , object variable aren't retained?
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
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?? ^^;
Mmm I wonder if I can achieve something like this, Let me see
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
I think it's just simply it has no easy way to store it like the Variables Panel needs the GameObject so it can access the Variables component when editing the GraphAsset it does not have access to this component/GameObject.
I think it was just an oversight or the developers did not think to add Object variables that are tied to the Asset
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
It's more like it forces Variables Component to have these variables once added.
ah yeah, you did say that
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
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
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
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.
-
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.
-
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
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.
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
Yeah exactly. Not a prpblem at all really. And the caveat is gentle enough
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
Do mean of the Community Addon's or do you mean any addon in General?
mmm this I am not sure of it sounds quite complicated or at least a mod-manager does.
But I was thinking of modularizing the addons, not completely sure how do-able it is yet but it would be nice to not install the entire thing just for a single feature
yeah, the add-ons
absolutely not urgent or even necessary lol
Yeah, it does seem like quite a big task. But i will definitely work on it in the future
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
Oh i see the problem Assets/Prefabs cannot serialize Scene objects after a reload they loose their reference to the scene and object it would only serialize correctly if the GameObject stayed in the scene I dont think there is a way to get around that. You should be able to use a Scene variable though and store the camera in that.
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