示例#1
0
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton)))
            {
                showTagHelp = !showTagHelp;
            }
            EditorGUILayout.EndHorizontal();

            if (showTagHelp)
            {
                DrawTagHelpLabel();
            }

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.PropertyField(storyTextProp);

            Say t = target as Say;

            if (t.character != null &&
                t.character.profileSprite != null &&
                t.character.profileSprite.texture != null)
            {
                Texture2D characterTexture = t.character.profileSprite.texture;

                float           aspect          = (float)characterTexture.width / (float)characterTexture.height;
                Rect            previewRect     = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor;
                characterEditor.DrawPreview(previewRect, characterTexture);
                DestroyImmediate(characterEditor);
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();

            CommandEditor.ObjectField <Character>(characterProp,
                                                  new GUIContent("Character", "Character to display in dialog"),
                                                  new GUIContent("<None>"),
                                                  Character.activeCharacters);

            EditorGUILayout.PropertyField(voiceOverClipProp,
                                          new GUIContent("Voice Over Clip", "Voice over audio to play when the say text is displayed"));

            EditorGUILayout.PropertyField(showOnceProp, new GUIContent("Show Once", "Show this text once and never show it again."));

            serializedObject.ApplyModifiedProperties();
        }
示例#2
0
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            ChooseOption t = target as ChooseOption;

            CommandEditor.ObjectField <Character>(characterProp,
                                                  new GUIContent("Character", "Character to display in dialog"),
                                                  new GUIContent("<None>"),
                                                  Character.activeCharacters);

            CommandEditor.ObjectField <ChooseDialog>(chooseDialogProp,
                                                     new GUIContent("Choose Dialog", "Choose Dialog object to use to display the multiple player choices"),
                                                     new GUIContent("<Default>"),
                                                     ChooseDialog.activeDialogs);

            bool showPortraits = false;

            // Only show portrait selection if...
            if (t.character != null &&                            // Character is selected
                t.character.portraits != null &&                  // Character has a portraits field
                t.character.portraits.Count > 0)                  // Selected Character has at least 1 portrait
            {
                showPortraits = true;
            }

            if (showPortraits)
            {
                CommandEditor.ObjectField <Sprite>(portraitProp,
                                                   new GUIContent("Portrait", "Portrait representing speaking character"),
                                                   new GUIContent("<None>"),
                                                   t.character.portraits);
            }
            else
            {
                t.portrait = null;
            }

            EditorGUILayout.PropertyField(chooseTextProp);

            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();
            if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton)))
            {
                showTagHelp = !showTagHelp;
            }
            EditorGUILayout.EndHorizontal();

            if (showTagHelp)
            {
                SayEditor.DrawTagHelpLabel();
            }

            EditorGUILayout.Separator();

            EditorGUILayout.PropertyField(voiceOverClipProp, new GUIContent("Voice Over Clip", "Voice over audio to play when the choose text is displayed"));

            EditorGUILayout.PropertyField(timeoutDurationProp, new GUIContent("Timeout Duration", "Time limit for player to make a choice. Set to 0 for no limit."));

            if (showPortraits && t.portrait != null)
            {
                Texture2D characterTexture = t.portrait.texture;

                float aspect = (float)characterTexture.width / (float)characterTexture.height;

                Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true));

                CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor;
                characterEditor.DrawPreview(previewRect, characterTexture);
                DestroyImmediate(characterEditor);
            }

            serializedObject.ApplyModifiedProperties();
        }
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            Portrait t = target as Portrait;

            if (PortraitStage.activePortraitStages.Count > 1)
            {
                CommandEditor.ObjectField <PortraitStage>(portraitStageProp,
                                                          new GUIContent("Portrait Stage", "Stage to display the character portraits on"),
                                                          new GUIContent("<Default>"),
                                                          PortraitStage.activePortraitStages);
            }
            // Format Enum names
            string[] displayLabels = StringFormatter.formatEnumNames(t.display, "<None>");
            displayProp.enumValueIndex = EditorGUILayout.Popup("Display", (int)displayProp.enumValueIndex, displayLabels);

            string characterLabel = "Character";

            if (t.display == displayType.Swap)
            {
                CommandEditor.ObjectField <Character>(replacedCharacterProp,
                                                      new GUIContent("Replace", "Character to swap with"),
                                                      new GUIContent("<None>"),
                                                      Character.activeCharacters);
                characterLabel = "With";
            }

            CommandEditor.ObjectField <Character>(characterProp,
                                                  new GUIContent(characterLabel, "Character to display"),
                                                  new GUIContent("<None>"),
                                                  Character.activeCharacters);

            bool          showOptionalFields = true;
            PortraitStage ps = t.portraitStage;

            // Only show optional portrait fields once required fields have been filled...
            if (t.character != null)                            // Character is selected
            {
                if (t.character.portraits == null ||            // Character has a portraits field
                    t.character.portraits.Count <= 0)           // Character has at least one portrait
                {
                    EditorGUILayout.HelpBox("This character has no portraits. Please add portraits to the character's prefab before using this command.", MessageType.Error);
                    showOptionalFields = false;
                }
                if (t.portraitStage == null)                            // If default portrait stage selected
                {
                    ps = t.GetFungusScript().defaultPortraitStage;;     // Try to get game's default portrait stage
                    if (t.portraitStage == null)                        // If no default specified, try to get any portrait stage in the scene
                    {
                        ps = GameObject.FindObjectOfType <PortraitStage>();
                    }
                }
                if (ps == null)
                {
                    EditorGUILayout.HelpBox("No portrait stage has been set. Please create a new portrait stage using [Game Object > Fungus > Portrait > Portrait Stage].", MessageType.Error);
                    showOptionalFields = false;
                }
            }
            if (t.display != displayType.NULL && t.character != null && showOptionalFields)
            {
                if (t.display != displayType.Hide && t.display != displayType.MoveToFront)
                {
                    // PORTRAIT
                    CommandEditor.ObjectField <Sprite>(portraitProp,
                                                       new GUIContent("Portrait", "Portrait representing character"),
                                                       new GUIContent("<Previous>"),
                                                       t.character.portraits);
                    if (t.character.portraitsFace != facingDirection.NULL)
                    {
                        // FACING
                        // Display the values of the facing enum as <-- and --> arrows to avoid confusion with position field
                        string[] facingArrows = new string[]
                        {
                            "<Previous>",
                            "<--",
                            "-->",
                        };
                        facingProp.enumValueIndex = EditorGUILayout.Popup("Facing", (int)facingProp.enumValueIndex, facingArrows);
                    }
                    else
                    {
                        t.facing = facingDirection.NULL;
                    }
                }
                else
                {
                    t.portrait = null;
                    t.facing   = facingDirection.NULL;
                }
                string toPositionPrefix = "";
                if (t.move)
                {
                    // MOVE
                    EditorGUILayout.PropertyField(moveProp);
                }
                if (t.move)
                {
                    if (t.display != displayType.Hide)
                    {
                        // START FROM OFFSET
                        EditorGUILayout.PropertyField(shiftIntoPlaceProp);
                    }
                }
                if (t.move)
                {
                    if (t.display != displayType.Hide)
                    {
                        if (t.shiftIntoPlace)
                        {
                            t.fromPosition = null;
                            // OFFSET
                            // Format Enum names
                            string[] offsetLabels = StringFormatter.formatEnumNames(t.offset, "<Previous>");
                            offsetProp.enumValueIndex = EditorGUILayout.Popup("From Offset", (int)offsetProp.enumValueIndex, offsetLabels);
                        }
                        else
                        {
                            t.offset = positionOffset.NULL;
                            // FROM POSITION
                            CommandEditor.ObjectField <RectTransform>(fromPositionProp,
                                                                      new GUIContent("From Position", "Move the portrait to this position"),
                                                                      new GUIContent("<Previous>"),
                                                                      ps.positions);
                        }
                    }
                    toPositionPrefix = "To ";
                }
                else
                {
                    t.shiftIntoPlace = false;
                    t.fromPosition   = null;
                    toPositionPrefix = "At ";
                }
                if (t.display == displayType.Show || (t.display == displayType.Hide && t.move))
                {
                    // TO POSITION
                    CommandEditor.ObjectField <RectTransform>(toPositionProp,
                                                              new GUIContent(toPositionPrefix + "Position", "Move the portrait to this position"),
                                                              new GUIContent("<Previous>"),
                                                              ps.positions);
                }
                else
                {
                    t.toPosition = null;
                }
                if (!t.move && t.display != displayType.MoveToFront)
                {
                    // MOVE
                    EditorGUILayout.PropertyField(moveProp);
                }
                if (t.display != displayType.MoveToFront)
                {
                    EditorGUILayout.Separator();

                    // USE DEFAULT SETTINGS
                    EditorGUILayout.PropertyField(useDefaultSettingsProp);
                    if (!t.useDefaultSettings)
                    {
                        // FADE DURATION
                        EditorGUILayout.PropertyField(fadeDurationProp);
                        if (t.move)
                        {
                            // MOVE SPEED
                            EditorGUILayout.PropertyField(moveSpeedProp);
                        }
                        if (t.shiftIntoPlace)
                        {
                            // SHIFT OFFSET
                            EditorGUILayout.PropertyField(shiftOffsetProp);
                        }
                    }
                }
                else
                {
                    t.move = false;
                    t.useDefaultSettings = true;
                    EditorGUILayout.Separator();
                }

                EditorGUILayout.PropertyField(waitUntilFinishedProp);

                if (t.portrait != null && t.display != displayType.Hide)
                {
                    EditorGUILayout.Separator();

                    Texture2D       characterTexture = t.portrait.texture;
                    float           aspect           = (float)characterTexture.width / (float)characterTexture.height;
                    Rect            previewRect      = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true));
                    CharacterEditor characterEditor  = Editor.CreateEditor(t.character) as CharacterEditor;
                    characterEditor.DrawPreview(previewRect, characterTexture);
                    DestroyImmediate(characterEditor);
                }
                if (t.display != displayType.Hide)
                {
                    string portraitName = "<Previous>";
                    if (t.portrait != null)
                    {
                        portraitName = t.portrait.name;
                    }
                    string   portraitSummary = " " + portraitName;
                    int      toolbarInt      = 1;
                    string[] toolbarStrings  = { "<--", portraitSummary, "-->" };
                    toolbarInt = GUILayout.Toolbar(toolbarInt, toolbarStrings, GUILayout.MinHeight(20));
                    int portraitIndex = -1;
                    if (toolbarInt != 1)
                    {
                        for (int i = 0; i < t.character.portraits.Count; i++)
                        {
                            if (portraitName == t.character.portraits[i].name)
                            {
                                portraitIndex = i;
                            }
                        }
                    }
                    if (toolbarInt == 0)
                    {
                        if (portraitIndex > 0)
                        {
                            t.portrait = t.character.portraits[--portraitIndex];
                        }
                        else
                        {
                            t.portrait = null;
                        }
                    }
                    if (toolbarInt == 2)
                    {
                        if (portraitIndex < t.character.portraits.Count - 1)
                        {
                            t.portrait = t.character.portraits[++portraitIndex];
                        }
                    }
                }
            }
            serializedObject.ApplyModifiedProperties();
        }