Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Equivalent to OnStart in Monobehavior

Discussion in 'Visual Scripting' started by xbi21, Jul 5, 2022.

  1. xbi21

    xbi21

    Joined:
    Jun 11, 2022
    Posts:
    5
    When i build custom nodes i sometimes need to initzilize values that i can't do in the constructor. Is there a function in visual scripting that is the equivalent of Start() or OnEnter()? I would like to avoid creating a flow input for this.

    Thanks
     
    Last edited: Jul 6, 2022
  2. Deleted User

    Deleted User

    Guest

    Yeah, there is a start node.
     
  3. xbi21

    xbi21

    Joined:
    Jun 11, 2022
    Posts:
    5
    Thanks, but I'm looking for a function that I can use in my Unit Class. Something like:

    Code (CSharp):
    1. void onStart()
    2. {
    3. //Init stuff
    4. }
     
  4. Deleted User

    Deleted User

    Guest

    Could you show me your code you want to execute on the objects start?
     
  5. xbi21

    xbi21

    Joined:
    Jun 11, 2022
    Posts:
    5
    Mainly initzalisations like:


    Code (CSharp):
    1. myString= flow.GetValue<string>(inputString);
    2.  
    3. //or
    4.  
    5. _audioMixer = Resources.Load<AudioMixer>("Mixers/master");
    6.             string mix= id;
    7.             var groups = _audioMixer.FindMatchingGroups(mix);
    8.             if (groups.Length > 0)
    9.             {
    10.                 _audioGroup = groups[0];
    11.             }
    12.  
     
  6. Deleted User

    Deleted User

    Guest

    Use the blackboard to set predefined variables