Exemple #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)
            {
                SayEditor.DrawTagHelpLabel();
            }

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.PropertyField(chooseTextProp);

            Choose t = target as Choose;

            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 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."));

            serializedObject.ApplyModifiedProperties();
        }
Exemple #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();
        }