Ejemplo n.º 1
0
                private bool DrawAddBackgroundLogicButton()
                {
                    int index = 0;

                    Type[] branchTypes = SystemUtils.GetAllSubTypes(typeof(BranchingBackgroundLogic));

                    string[] branchTypeNames = new string[branchTypes.Length + 1];
                    branchTypeNames[index++] = "(Add Background Logic)";

                    foreach (Type type in branchTypes)
                    {
                        branchTypeNames[index] = type.Name;
                        index++;
                    }

                    int newIndex = EditorGUILayout.Popup(string.Empty, 0, branchTypeNames);

                    if (0 != newIndex)
                    {
                        Type branchType = branchTypes[newIndex - 1];

                        BranchingBackgroundLogic newBackgroundLogic = Activator.CreateInstance(branchType) as BranchingBackgroundLogic;
                        EventStartBranchingState evnt = GetEditableObject() as EventStartBranchingState;

                        ArrayUtils.Add(ref evnt._backgroundLogic, newBackgroundLogic);

                        GetTimelineEditor().GetParent().OnAddedNewXmlNode(newBackgroundLogic);

                        return(true);
                    }

                    return(false);
                }
Ejemplo n.º 2
0
                public override bool RenderObjectProperties(GUIContent label)
                {
                    Color orig = GUI.backgroundColor;
                    EventStartBranchingState evnt = GetEditableObject() as EventStartBranchingState;

                    bool dataChanged = false;

                    #region Render Brances
                    EditorGUILayout.LabelField("Branches:", EditorStyles.boldLabel);
                    EditorGUILayout.Separator();

                    for (int i = 0; i < evnt._branches.Length; i++)
                    {
                        GUI.backgroundColor = _branchLabelColor;
                        EditorGUILayout.LabelField(GetBranchLabel(evnt._branches[i], i == 0), EditorUtils.TextTitleStyle, GUILayout.Height(24.0f));
                        GUI.backgroundColor = orig;

                        //Draw branch properties
                        bool branchChanged;
                        SerializedObjectEditorGUILayout.ObjectField(evnt._branches[i], string.Empty, out branchChanged);
                        dataChanged |= branchChanged;

                        if (DrawEditBranchButtons(i))
                        {
                            dataChanged = true;
                            break;
                        }
                    }

                    dataChanged |= DrawAddBranchButton();
                    #endregion

                    EditorGUILayout.Separator();
                    EditorGUILayout.Separator();

                    #region Render Background Logic Threads
                    EditorGUILayout.LabelField("Background Logic:", EditorStyles.boldLabel);
                    EditorGUILayout.Separator();

                    for (int i = 0; i < evnt._backgroundLogic.Length; i++)
                    {
                        BranchingBackgroundLogic backgroundLogic = evnt._backgroundLogic[i];

                        GUI.backgroundColor = _branchLabelColor;
                        EditorGUILayout.LabelField(backgroundLogic.GetDescription(), EditorUtils.TextTitleStyle, GUILayout.Height(24.0f));
                        GUI.backgroundColor = orig;

                        //Draw backgroundLogic properties
                        {
                            int origIndent = EditorGUI.indentLevel;
                            EditorGUI.indentLevel++;

                            bool objectChanged;
                            backgroundLogic = SerializedObjectEditorGUILayout.ObjectField(backgroundLogic, "", out objectChanged);
                            dataChanged    |= objectChanged;

                            EditorGUI.indentLevel = origIndent;
                        }

                        if (DrawEditBackgroundLogicButtons(i))
                        {
                            dataChanged = true;
                            break;
                        }
                    }

                    dataChanged |= DrawAddBackgroundLogicButton();
                    #endregion

                    return(dataChanged);
                }