/// <summary> Рендерит Getter переменной. </summary>
        public void RenderVariableGetter()
        {
            VariableGetter node = Render(Prefabs.Nodes.VariableGetter).GetComponent <VariableGetter>();

            node.Initialize(variable);

            Manager.ContextManager.DestroyMenu();
        }
Пример #2
0
        void DrawInspector()
        {
            if (selectedNode == null)
            {
                return;
            }

            //			Debug.Log (selectedNode);

            //			if (Event.current.type != EventType.Repaint || Event.current.type != EventType.Layout || Event.current.type != )
            //				return;

            GUIStyle nodeTypeStyle = new GUIStyle(EditorStyles.label);

            nodeTypeStyle.alignment = TextAnchor.UpperCenter;
            nodeTypeStyle.fontStyle = FontStyle.Bold;
            EditorGUILayout.LabelField(selectedNode.Id, nodeTypeStyle);
            DrawId();

            if (_fields != null)
            {
                for (int i = 0; i < _fields.Count; i++)
                {
                    EditorGUILayout.Separator();
                    EditorGUILayout.BeginVertical();

                    FieldInfo field     = _fields[i];
                    string    fieldName = field.Name;
                    NodeField nodeField = _fieldToAttributeDict[field];

                    if (nodeField.GetType() == typeof(NodeField))
                    {
                        CustomFieldDrawer customFieldDrawer = CustomFieldDrawerManager.GetCustomFieldDrawer(field.FieldType);
                        if (customFieldDrawer == null)
                        {
                            // draw normally if you can...?
                            if (field.FieldType == typeof(bool))
                            {
                                field.SetValue(selectedNode, EditorGUILayout.ToggleLeft(nodeField.label, (bool)field.GetValue(selectedNode)));
                            }
                        }
                        else
                        {
                            customFieldDrawer.targetField = field;
                            customFieldDrawer.targetNode  = selectedNode;
                            customFieldDrawer.Draw();
                        }
                    }
                    else if (nodeField.GetType() == typeof(VariableGetter))
                    {
                        VariableGetter getterAttr = (VariableGetter)nodeField;
                        if (getterAttr.overrideField == null)
                        {
                            // no override just draw normal
                            DrawVariableDropdown(field, getterAttr);
                        }
                        else
                        {
                            string fieldValue = (string)field.GetValue(selectedNode);
                            if (fieldValue == null)
                            {
                                // draw field normally
                            }
                        }
                    }
                    else if (nodeField.GetType() == typeof(VariableSetter))
                    {
                        VariableSetter setterAttr = (VariableSetter)nodeField;
                        DrawVariableDropdown(field, setterAttr);
                    }

                    EditorGUILayout.EndVertical();
                }

                // EditorGUILayout.BeginVertical(EditorStyles.textArea);


                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("Comments");
                GUIStyle commentStyle = new GUIStyle(EditorStyles.textArea);
                commentStyle.fixedHeight = 100;
                EditorGUILayout.TextArea("", commentStyle);
            }

            if (Application.isPlaying)
            {
                EditorGUILayout.TextArea(selectedNode.StateMessage, GUILayout.Height(60));
            }

            if (redrawInspector)
            {
                GUI.FocusControl(null);
                redrawInspector = false;
            }
        }
Пример #3
0
 public void setGetter(VariableGetter aVariableGetter)
 {
     getter = aVariableGetter;
 }