Esempio n. 1
0
        public override void DrawCommandGUI()
        {
            var flowchart = FlowchartWindow.GetFlowchart();

            if (flowchart == null)
            {
                return;
            }

            serializedObject.Update();

            EditorGUILayout.PropertyField(textProp);

            EditorGUILayout.PropertyField(descriptionProp);

            BlockEditor.BlockField(targetBlockProp,
                                   new GUIContent("Target Block", "Block to call when option is selected"),
                                   new GUIContent("<None>"),
                                   flowchart);

            EditorGUILayout.PropertyField(hideIfVisitedProp);
            EditorGUILayout.PropertyField(interactableProp);
            EditorGUILayout.PropertyField(setMenuDialogProp);
            EditorGUILayout.PropertyField(hideThisOptionProp);

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 2
0
        protected static void ExportReferenceDocs()
        {
            const string path = "./Docs";

            ExportCommandInfo(path);
            ExportEventHandlerInfo(path);

            FlowchartWindow.ShowNotification("Exported Reference Documentation");
        }
Esempio n. 3
0
        public override void OnInspectorGUI()
        {
            if (GUILayout.Button(new GUIContent("Delete Save Data", "Deletes the save data associated with the Save Data Key from PlayerPrefs")))
            {
                var saveMenu = target as SaveMenu;

                if (saveMenu != null)
                {
                    PlayerPrefs.DeleteKey(saveMenu.SaveDataKey);
                    FlowchartWindow.ShowNotification("Deleted Save Data");
                }
            }

            base.OnInspectorGUI();
        }
Esempio n. 4
0
        public override void DrawCommandGUI()
        {
            var flowchart = FlowchartWindow.GetFlowchart();

            if (flowchart == null)
            {
                return;
            }

            serializedObject.Update();

            EditorGUILayout.PropertyField(durationProp);

            BlockEditor.BlockField(targetBlockProp,
                                   new GUIContent("Target Block", "Block to call when timer expires"),
                                   new GUIContent("<None>"),
                                   flowchart);

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 5
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            VariablePropertyAttribute variableProperty = attribute as VariablePropertyAttribute;

            if (variableProperty == null)
            {
                return;
            }

            EditorGUI.BeginProperty(position, label, property);

            // Filter the variables by the types listed in the VariableProperty attribute
            Func <Variable, bool> compare = v =>
            {
                if (v == null)
                {
                    return(false);
                }

                if (variableProperty.VariableTypes.Length == 0)
                {
                    return(true);
                }

                return(variableProperty.VariableTypes.Contains <System.Type>(v.GetType()));
            };

            VariableEditor.VariableField(property,
                                         label,
                                         FlowchartWindow.GetFlowchart(),
                                         variableProperty.defaultText,
                                         compare,
                                         (s, t, u) => (EditorGUI.Popup(position, s, t, u)));

            EditorGUI.EndProperty();
        }
Esempio n. 6
0
        Command AddNewCommand()
        {
            Flowchart flowchart = FlowchartWindow.GetFlowchart();

            if (flowchart == null)
            {
                return(null);
            }

            var block = flowchart.SelectedBlock;

            if (block == null)
            {
                return(null);
            }

            var newCommand = Undo.AddComponent <Comment>(block.gameObject) as Command;

            newCommand.ItemId = flowchart.NextItemId();
            flowchart.ClearSelectedCommands();
            flowchart.AddSelectedCommand(newCommand);

            return(newCommand);
        }
Esempio n. 7
0
 protected virtual void ShowNotification(Localization localization)
 {
     FlowchartWindow.ShowNotification(localization.NotificationText);
     localization.NotificationText = "";
 }
Esempio n. 8
0
        public void DrawItem(Rect position, int index)
        {
            Variable variable = this[index].objectReferenceValue as Variable;

            if (variable == null)
            {
                return;
            }

            int width      = widthOfList;
            int totalRatio = DefaultWidth;


            float[] widths = { (80.0f / totalRatio) * width,
                               (100.0f / totalRatio) * width,
                               (140.0f / totalRatio) * width,
                               (60.0f / totalRatio) * width };
            Rect[]  rects = new Rect[4];

            for (int i = 0; i < 4; ++i)
            {
                rects[i]       = position;
                rects[i].width = widths[i] - 5;

                for (int j = 0; j < i; ++j)
                {
                    rects[i].x += widths[j];
                }
            }

            VariableInfoAttribute variableInfo = VariableEditor.GetVariableInfo(variable.GetType());

            if (variableInfo == null)
            {
                return;
            }

            var flowchart = FlowchartWindow.GetFlowchart();

            if (flowchart == null)
            {
                return;
            }

            // Highlight if an active or selected command is referencing this variable
            bool highlight = false;

            if (flowchart.SelectedBlock != null)
            {
                if (Application.isPlaying && flowchart.SelectedBlock.IsExecuting())
                {
                    highlight = flowchart.SelectedBlock.ActiveCommand.HasReference(variable);
                }
                else if (!Application.isPlaying && flowchart.SelectedCommands.Count > 0)
                {
                    foreach (Command selectedCommand in flowchart.SelectedCommands)
                    {
                        if (selectedCommand == null)
                        {
                            continue;
                        }

                        if (selectedCommand.HasReference(variable))
                        {
                            highlight = true;
                            break;
                        }
                    }
                }
            }

            if (highlight)
            {
                GUI.backgroundColor = Color.green;
                GUI.Box(position, "");
            }

            string        key   = variable.Key;
            VariableScope scope = variable.Scope;

            // To access properties in a monobehavior, you have to new a SerializedObject
            // http://answers.unity3d.com/questions/629803/findrelativeproperty-never-worked-for-me-how-does.html
            SerializedObject variableObject = new SerializedObject(this[index].objectReferenceValue);

            variableObject.Update();

            GUI.Label(rects[0], variableInfo.VariableType);

            key = EditorGUI.TextField(rects[1], variable.Key);
            SerializedProperty keyProp     = variableObject.FindProperty("key");
            SerializedProperty defaultProp = variableObject.FindProperty("value");
            SerializedProperty scopeProp   = variableObject.FindProperty("scope");

            keyProp.stringValue = flowchart.GetUniqueVariableKey(key, variable);

            bool isGlobal = scopeProp.enumValueIndex == (int)VariableScope.Global;


            if (isGlobal && Application.isPlaying)
            {
                var res = FungusManager.Instance.GlobalVariables.GetVariable(keyProp.stringValue);
                if (res != null)
                {
                    SerializedObject globalValue = new SerializedObject(res);
                    var globalValProp            = globalValue.FindProperty("value");

                    var prevEnabled = GUI.enabled;
                    GUI.enabled = false;

                    EditorGUI.PropertyField(rects[2], globalValProp, new GUIContent(""));

                    GUI.enabled = prevEnabled;
                }
            }
            else
            {
                EditorGUI.PropertyField(rects[2], defaultProp, new GUIContent(""));
            }


            scope = (VariableScope)EditorGUI.EnumPopup(rects[3], variable.Scope);
            scopeProp.enumValueIndex = (int)scope;

            variableObject.ApplyModifiedProperties();

            GUI.backgroundColor = Color.white;
        }
Esempio n. 9
0
        public static void DrawView(View view, bool drawInterior)
        {
            float height = CalculateLocalViewSize(view);
            float widthA = height * (view.PrimaryAspectRatio.x / view.PrimaryAspectRatio.y);
            float widthB = height * (view.SecondaryAspectRatio.x / view.SecondaryAspectRatio.y);

            Color transparent = new Color(1, 1, 1, 0f);
            Color fill        = viewColor;
            Color outline     = viewColor;

            bool highlight = Selection.activeGameObject == view.gameObject;

            var flowchart = FlowchartWindow.GetFlowchart();

            if (flowchart != null)
            {
                var selectedCommands = flowchart.SelectedCommands;
                foreach (var command in selectedCommands)
                {
                    MoveToView moveToViewCommand = command as MoveToView;
                    if (moveToViewCommand != null &&
                        moveToViewCommand.TargetView == view)
                    {
                        highlight = true;
                    }
                    else
                    {
                        FadeToView fadeToViewCommand = command as FadeToView;
                        if (fadeToViewCommand != null &&
                            fadeToViewCommand.TargetView == view)
                        {
                            highlight = true;
                        }
                    }
                }
            }

            if (highlight)
            {
                fill      = outline = Color.green;
                fill.a    = 0.1f;
                outline.a = 1f;
            }
            else
            {
                fill.a    = 0.1f;
                outline.a = 0.5f;
            }

            if (drawInterior)
            {
                // Draw left box
                {
                    Vector3[] verts = new Vector3[4];
                    verts[0] = view.transform.TransformPoint(new Vector3(-widthB, -height, 0));
                    verts[1] = view.transform.TransformPoint(new Vector3(-widthB, height, 0));
                    verts[2] = view.transform.TransformPoint(new Vector3(-widthA, height, 0));
                    verts[3] = view.transform.TransformPoint(new Vector3(-widthA, -height, 0));

                    Handles.DrawSolidRectangleWithOutline(verts, fill, transparent);
                }

                // Draw right box
                {
                    Vector3[] verts = new Vector3[4];
                    verts[0] = view.transform.TransformPoint(new Vector3(widthA, -height, 0));
                    verts[1] = view.transform.TransformPoint(new Vector3(widthA, height, 0));
                    verts[2] = view.transform.TransformPoint(new Vector3(widthB, height, 0));
                    verts[3] = view.transform.TransformPoint(new Vector3(widthB, -height, 0));

                    Handles.DrawSolidRectangleWithOutline(verts, fill, transparent);
                }

                // Draw inner box
                {
                    Vector3[] verts = new Vector3[4];
                    verts[0] = view.transform.TransformPoint(new Vector3(-widthA, -height, 0));
                    verts[1] = view.transform.TransformPoint(new Vector3(-widthA, height, 0));
                    verts[2] = view.transform.TransformPoint(new Vector3(widthA, height, 0));
                    verts[3] = view.transform.TransformPoint(new Vector3(widthA, -height, 0));

                    Handles.DrawSolidRectangleWithOutline(verts, transparent, outline);
                }
            }

            // Draw outer box
            {
                Vector3[] verts = new Vector3[4];
                verts[0] = view.transform.TransformPoint(new Vector3(-widthB, -height, 0));
                verts[1] = view.transform.TransformPoint(new Vector3(-widthB, height, 0));
                verts[2] = view.transform.TransformPoint(new Vector3(widthB, height, 0));
                verts[3] = view.transform.TransformPoint(new Vector3(widthB, -height, 0));

                Handles.DrawSolidRectangleWithOutline(verts, transparent, outline);
            }
        }