Esempio n. 1
0
        public static void PortRename(this Node self, NodePort port, string newName)
        {
            if (port == null)
            {
                return;
            }

            var oldName = port.fieldName;

            var fieldNameFieldInfo = port.GetType().GetField(NodePort.FieldNameEditor, BindingFlags.Instance | BindingFlags.NonPublic);

            fieldNameFieldInfo.SetValue(port, newName);

            SerializedObject nodeSerObj = new SerializedObject(self);

            var portsSer = nodeSerObj.FindProperty(Node.PortFieldName);

            var keysSer = portsSer.FindPropertyRelative(Node.KeysFieldName);

            for (var i = 0; i < keysSer.arraySize; i++)
            {
                if (keysSer.GetArrayElementAtIndex(i).stringValue == oldName)
                {
                    keysSer.GetArrayElementAtIndex(i).stringValue = newName;
                    break;
                }
            }

            nodeSerObj.ApplyModifiedProperties();

            EditorUtility.SetDirty(self);
        }
Esempio n. 2
0
    // Surely this process can be automated?!
    // using runtime reflection
    public override object GetValue(NodePort port)
    {
        switch (port.GetType().Name)
        {
        case "XRotation":
            return(XRotation);

        case "YRotation":
            return(YRotation);

        case "ZRotation":
            return(ZRotation);

        default:
            return(0f);
        }
    }
Esempio n. 3
0
    // Surely this process can be automated?!
    // using runtime reflection
    public override object GetValue(NodePort port)
    {
        switch (port.GetType().Name)
        {
        case "SpeedX":
            return(SpeedX);

        case "SpeedY":
            return(SpeedY);

        case "SpeedZ":
            return(SpeedZ);

        default:
            return(0f);
        }
    }