コード例 #1
0
            public bool RenderObjectProperties(GUIContent label)
            {
                bool dataChanged = false;

                if (label == null)
                {
                    label = new GUIContent();
                }

                label.text += " (" + (typeof(T) == typeof(float) ? "float" : typeof(T).Name) + ")";

                _editorFoldout = EditorGUILayout.Foldout(_editorFoldout, label);
                if (_editorFoldout)
                {
                    int origIndent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel++;

                    _sourceType = SerializationEditorGUILayout.ObjectField(_sourceType, new GUIContent("Input Type", "Static: Value will be constant.\nNode: Value read from other nodes output."), ref dataChanged);
                    if (dataChanged)
                    {
                        ClearStaticValue();
                        _sourceNodeId = -1;
                    }

                    switch (_sourceType)
                    {
                    case eSourceType.Static:
                    {
                        SerializationEditorGUILayout.RenderObjectMemebers(this, GetType(), ref dataChanged);
                    }
                    break;

                    case eSourceType.Node:
                    {
                        dataChanged |= DrawNodeNamePopUps();
                    }
                    break;
                    }

                    EditorGUI.indentLevel = origIndent;
                }

                return(dataChanged);
            }
コード例 #2
0
                public static object PropertyField(object obj, GUIContent label, ref bool dataChanged, GUIStyle style, params GUILayoutOption[] options)
                {
                    Condition currentConditional = (Condition)obj;
                    Condition conditional        = DrawAddConditionalDropDown("Condition", currentConditional);

                    if (conditional != currentConditional)
                    {
                        dataChanged = true;
                    }

                    int origIndent = EditorGUI.indentLevel;

                    EditorGUI.indentLevel++;

                    if (conditional != null)
                    {
                        conditional = DrawToggle(conditional, ref dataChanged);

                        bool editorCollapsed = !EditorGUILayout.Foldout(!conditional._editorCollapsed, "Properties");

                        if (editorCollapsed != conditional._editorCollapsed)
                        {
                            conditional._editorCollapsed = editorCollapsed;
                            dataChanged = true;
                        }

                        if (!editorCollapsed)
                        {
                            EditorGUI.indentLevel++;

                            conditional = (Condition)SerializationEditorGUILayout.RenderObjectMemebers(conditional, conditional.GetType(), ref dataChanged);

                            EditorGUI.indentLevel--;
                        }
                    }

                    EditorGUI.indentLevel = origIndent;

                    return(conditional);
                }
コード例 #3
0
                public static object PropertyField(object obj, GUIContent label, ref bool dataChanged, GUIStyle style, params GUILayoutOption[] options)
                {
                    Condition currentConditional = (Condition)obj;
                    Condition conditional        = ConditionEditor.DrawAddConditionalDropDown("Condition", currentConditional);

                    if (conditional != currentConditional)
                    {
                        dataChanged = true;
                    }

                    int origIndent = EditorGUI.indentLevel;

                    EditorGUI.indentLevel++;

                    if (conditional != null)
                    {
                        conditional = ConditionEditor.DrawToggle(conditional, ref dataChanged);

                        bool editorCollapsed = !EditorGUILayout.Foldout(!conditional._editorCollapsed, "Properties");

                        if (editorCollapsed != conditional._editorCollapsed)
                        {
                            conditional._editorCollapsed = editorCollapsed;
                            dataChanged = true;
                        }

                        if (!editorCollapsed)
                        {
                            EditorGUI.indentLevel++;

                            ConditionSaveDataEnum saveDataEnum = conditional as ConditionSaveDataEnum;

                            if (saveDataEnum != null)
                            {
                                //Save data type (only show enum properties)
                                saveDataEnum._saveData = SerializationEditorGUILayout.ObjectField(saveDataEnum._saveData, GUIContent.none, ref dataChanged);

                                //Possible values
                                Type enumType = saveDataEnum.GetEnumType();

                                if (enumType != null)
                                {
                                    Enum enm = (Enum)Enum.ToObject(enumType, saveDataEnum._value);
                                    EditorGUI.BeginChangeCheck();
                                    saveDataEnum._enumValue = EditorGUILayout.EnumPopup("Value", enm);
                                    if (EditorGUI.EndChangeCheck())
                                    {
                                        saveDataEnum._value = Convert.ToInt32(saveDataEnum._enumValue);
                                        dataChanged         = true;
                                    }
                                }
                                else
                                {
                                    saveDataEnum._enumValue = null;
                                    saveDataEnum._value     = -1;
                                }
                            }
                            else
                            {
                                conditional = (Condition)SerializationEditorGUILayout.RenderObjectMemebers(conditional, conditional.GetType(), ref dataChanged);
                            }

                            EditorGUI.indentLevel--;
                        }
                    }

                    EditorGUI.indentLevel = origIndent;

                    return(conditional);
                }