Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Simple node editor

Discussion in 'Extensions & OnGUI' started by unimechanic, Jul 5, 2013.

  1. brett_unity19

    brett_unity19

    Joined:
    May 1, 2018
    Posts:
    2
    First time post on Unity3D.... @Seneral - LOVE the node editor. I've been working with it for a couple of days and I'm looking for help on saving GameObjects referenced on a node. In my node definition, I have this variable name:


    [SerializeField]
    public GameObject ObjName;


    And in NodeGUI(), I have this:

    ObjName = (GameObject)EditorGUILayout.ObjectField(ObjName, typeof(GameObject), true, GUILayout.Width(250f), GUILayout.Height(20f));


    What else do I need to do to get the object to be saved? I suspect I'm not registering it correctly with the framework but didn't see how to do that.
     
  2. Seneral

    Seneral

    Joined:
    Jun 2, 2014
    Posts:
    1,121
    Just about to leave:p
    Theoretically it's correct, but if that GO (or any other object) is stored in a Scene instead of the AssetDatabase (like Prefab), you can't reference it while the Canvas is save in the AssetDatabase. That would create a reference that couldn't be resolved when that specific scene is not loaded.
    Instead, you have to save the canvas aalon with that GameObject in the same scene. Sometimes that conflicts with other design/plans, but it's the only way apart from saving just the name/etc. and finding it in the scene (assuming that scene is loaded) which would be better for managers that are in every scene.
    So you can save in the scene from tr same popup, it will simply create an empty object in the current scene with a wrapper component that holds a copy of that canvas. Unity will now save it correctly inside the scene an maintain scene references!
    Hope that helps,
    Seneral
     
  3. brett_unity19

    brett_unity19

    Joined:
    May 1, 2018
    Posts:
    2
    Oh. Glad I asked! Thanks so much.
     
  4. KrytalityStudios

    KrytalityStudios

    Joined:
    Sep 12, 2016
    Posts:
    16
    I have a quick question on the implementation details of basically only drawing a certain portion of the canvas. The situation is this, right now I'm implementing the different nodes to be saved to my database, and I've changed the database idea up a little so that there is a limit on one database per project. Since that is so, I need to have some way to draw only a certain portion of the canvas, say just a single conversation and be able to switch between the different conversations to edit. I was just wondering about the implementation into doing that.
     
  5. Seneral

    Seneral

    Joined:
    Jun 2, 2014
    Posts:
    1,121
    I'm not sure about your implementation, but you probably want to take a look at NodeEditor drawing loop, where the data of the canvas is processed. You probably have to select the correct NodeEditorState (view transformation, etc), the respective nodes and their connections only depending on what you want to draw.
    Sorry, on my trip atm, can't help you on code level.
     
  6. KrytalityStudios

    KrytalityStudios

    Joined:
    Sep 12, 2016
    Posts:
    16
    Thank you for your response! And that's fine because I have decided to roll my own sort of implementation of the Node Group class, called something like the NodeGroupVisible class or something like that, and basically the class will place all nodes created when it is active into its nodesToDraw var or something, and then that will allow the NodeEditor class to know what to draw in a nutshell. This will be the basis for allowing the UI to select a certain conversation or quest, and then only displaying the nodes related to that conversation or quest.

    The only thing is, and I may figure this out before you respond, but will not displaying the nodes stop them from getting messages? If so I guess somehow I could just create maybe something in the Node class that will make it stop responding to messages, but I don't really know. And it may not even be important o_O.

    Once again you really don't have to respond on a trip lol, but thanks anyway :)!
     
  7. Seneral

    Seneral

    Joined:
    Jun 2, 2014
    Posts:
    1,121
    Ya I'll try! :)
    If try are not drawn, there are no GUI controls at all, so they cannot be altered at all, if that is what you mean by receiving messages. Of course of you have a traversal routine in place, that would atils consider all notes (like the ccalculation routine). Also, if tgey have connections to visible nodes, those could of fourse interact with the invisible onces, in theory. But from the GUI perspective, they are simply non existent.
     
  8. KrytalityStudios

    KrytalityStudios

    Joined:
    Sep 12, 2016
    Posts:
    16
    So there is one issue right now, I have basically created a new list of groups that do what I said, but the issue is that the references to the nodes and the node canvas parent are not being saved in the group class I made, and I have marked it as serializable.

    So my question is how do you save this kind of stuff, because marking the group class as serializable is not saving the references to any SO objects.

    And so basically do I change it to a SO itself? This seems fairly logical but I will have to modify the save manager.

    I have tried to work around this by having some unique IDs for every node, but that has proven to be a pain so my options are as follows:

    Use unique IDs for every node and just work it out.
    Change the group class to an SO and modify the save manager a little (or maybe a lot idk)
    Just use the view transform to focus on a certain portion.
    Or, as I write this I thought this, do some trickery within the node class and do something similar to the dialogue editor example and just basically have some dialogue start node or quest start nodes, and all the ones connected are a part of the conversation/quest, allowing the node editor to only draw those groups of nodes in particular. Which seems like a good idea but yeah .

    Thanks again. Cheers!

    Quick edit: I have found something that may work with the unique ID solution and I am going to try it.
     
    Last edited: Jul 15, 2018 at 10:21 PM