edited June 2019 in Makinom Support
Hello! Non-coder here, but right now I want to learn a bit coding with Custom node :)
So... I start looking in the tutorial about creating custom node but doesn't know how to put the setting in the setting field in the line which is comment "// INFO: Place your settings here."
I have this code from other assets that can change their value which look like this:

public class ExampleClass : MonoBehaviour
public float MyValue;
public Progressor MyProgressor;

private void Start()
MyProgressor.SetValue(MyValue);

If I just copy and paste that code in the setting field then basically is work without error but... that is not what I want.

Basically, I just want this node to change 'SetValue' base on Makinom variable.
But I have no idea how to access Makinom variable.

So... can any coder teach me how?
Post edited by Night on
  • Is Progressor a component as well?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited June 2019
    Yes!
    So how do I change the Progressor component value base on Makinom variable?
    Post edited by Night on
  • Try this :)


    using UnityEngine;
    using System.Collections.Generic;

    namespace Makinom.Schematics.Nodes
    {
    [EditorHelp("Set Progressor Value", "", "")]
    [NodeInfo("Progressor")]
    public class NewSchematicNode : BaseSchematicNode
    {
    [EditorHelp("Value", "The value that will be used.", "")]
    public SchematicFloat value = new SchematicFloat(1);

    [EditorInfo(separator=true, titleLabel="Game Object")]
    public SchematicObjectSelection usedObject = new SchematicObjectSelection();

    [EditorHelp("Scope", "Select the scope of 'Progressor' component that will be used:\n" +
    "- Single: A single component attached to the game object.\n" +
    "- In Children: A single component attached to the game object or any child object.\n" +
    "- In Parent: A single component attached to the game object or any parent object.\n" +
    "- From Root: A single component attached to the game object's root or any child object (from the root).\n" +
    "- All: All component attached to the game object.\n" +
    "- All In Children: All component attached to the game object and child objects.\n" +
    "- All In Parent: All component attached to the game object and parent objects.\n" +
    "- All From Root: All component attached to the game object's root and child objects (from the root).", "")]
    public ComponentScope scope = ComponentScope.Single;

    public NewSchematicNode()
    {

    }

    public override void Execute(Schematic schematic)
    {
    List<Progressor> list = this.usedObject.GetAllComponents<Progressor>(schematic, this.scope);
    for(int i=0; i<list.Count; i++)
    {
    if(list[i] != null &&
    list[i].isActiveAndEnabled)
    {
    list[i].SetValue(this.value.GetValue(schematic));
    }
    }
    schematic.NodeFinished(this.next);
    }


    // INFO: This returns the text displayed in the node's info area.
    public override string GetNodeDetails()
    {
    return this.usedObject.ToString() + ": " + this.value.ToString();
    }

    // INFO: This property handles the color of your node in the node editor.
    public override Color EditorColor
    {
    get { return Maki.EditorSettings.baseNodeColor; }
    }
    }
    }
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Wow! Is work flawlessly!
    So can you explain a bit about the code?

    I can understand a little but not too much.
    [EditorHelp("Value", "The value that will be used.", "")]
    public SchematicFloat value = new SchematicFloat(1);

    So this line I understand is used to set the value to whatever I set it in the schematic node.
    So if I make another custom node I just need this line to set value?

    And this line:
    [EditorInfo(separator=true, titleLabel="Game Object")]
    public SchematicObjectSelection usedObject = new SchematicObjectSelection();

    Is for which game object I choose to be set on and also the Scope right?
    So basically if I want to change the value of what object meaning I have to use this 2 line?

    public override void Execute(Schematic schematic)
    {
    List<Progressor> list = this.usedObject.GetAllComponents<Progressor>(schematic, this.scope);
    for(int i=0; i<list.Count; i++)
    {
    if(list[i] != null &&
    list[i].isActiveAndEnabled)
    {
    list[i].SetValue(this.value.GetValue(schematic));
    }
    }
    schematic.NodeFinished(this.next);
    }

    And I have no idea what is this mean but I know what is for, is for searching the Components is this game object right?
    But only for this user object?
    Because this line say so.
    List<Progressor> list = this.usedObject.GetAllComponents<Progressor>(schematic, this.scope);
  • Generally, everything between the [ and ] are not needed, they're just some information for the ORK editor to e.g. add help texts to the settings.

    [EditorHelp("Value", "The value that will be used.", "")]<br>public SchematicFloat value = new SchematicFloat(1);
    The SchematicFloat class allows the whole float value selection settings that is available in schematics.
    You can get the value by calling this code: float tmp = this.value.GetValue(schematic);
    So, yes, you'd just need this in case you need a float value in your custom node.

    [EditorInfo(separator=true, titleLabel="Game Object")]<br>public SchematicObjectSelection usedObject = new SchematicObjectSelection();
    The SchematicObjectSelection class allows the schematic's object selection, e.g. actor or machine object, etc.
    It has different functions to get a single object or all objects that might be used (e.g. all instances of a spawned prefab), as well as getting things like components without having to first get the game objects.

    public override void Execute(Schematic schematic)
    {
    List<Progressor> list = this.usedObject.GetAllComponents<Progressor>(schematic, this.scope);
    for(int i = 0; i < list.Count; i++)
    {
    if(list[i] != null &&
    list[i].isActiveAndEnabled)
    {
    list[i].SetValue(this.value.GetValue(schematic));
    }
    }
    schematic.NodeFinished(this.next);
    }

    The Execute function is called when a node is performed. This here will first get all the Progressor components from the selected game object, goes through all of them (for loop), checks if they exist and are enabled (if) and sets their value.
    Finally, it'll let the schematic know that it finished and which node to perform next (schematic.NodeFinished call).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Ah! Now I understand it better! Thank you!
Sign In or Register to comment.