Пример #1
0
    static void Init()
    {
        // Get existing open window or if none, make a new one:
        ConversationEditor window = (ConversationEditor)GetWindow(typeof(ConversationEditor));

        window.Show();
        window.minSize = new Vector2(450, 450);
        GUIContent content = new GUIContent("Editor");

        window.titleContent = content;
        conversations.Clear();

        Conversation[] conver = Resources.LoadAll <Conversation>("Conversations");
        foreach (var item in conver)
        {
            string[] str = AssetDatabase.GetAssetPath(item).Split(new char[] { '/', '.' });
            conversations.Add(item);
            item.EditConversationName(str[str.Length - 2]);
        }

        if (conversations.Count > 0 && selectedConversation == null)
        {
            selectedConversation = conversations[0];
            CreateTreeStructure.AssignPositionToNodes(selectedConversation, nodeWidth, nodeHeight, nodeHorSpace, nodeVerSpace);
        }

        isAddingDialogue = false;

        InitializeTexture();
    }
Пример #2
0
    private void AddDialogue()
    {
        Dialogue newDialogue = new Dialogue(selectedConversation.Dialogues[selectedConversation.Dialogues.Count - 1].DialogueID + 1, characterName, sentence, bubbleTalkName);

        if (selectedDialogue == null)
        {
            Debug.Log("selectedNode is null...");
        }

        Debug.Log("Dialogue is added to DialogueID" + selectedDialogue.DialogueID + ", sentence : " + sentence);

        selectedConversation.AddDialogue(selectedDialogue, newDialogue);
        isAddingDialogue = false;
        CreateTreeStructure.AssignPositionToNodes(selectedConversation, nodeWidth, nodeHeight, nodeHorSpace, nodeVerSpace);
    }
Пример #3
0
    void OnGUI()
    {
        normalStyle = new GUIStyle()
        {
            fontStyle = FontStyle.BoldAndItalic,
            fontSize  = 15,
            alignment = TextAnchor.MiddleLeft
        };

        normalStyle.normal.textColor = Color.black;

        #region Header View
        Rect rect = new Rect(0, 0, Screen.width, headerHeight);
        GUILayout.BeginArea(rect);
        GUI.DrawTexture(rect, headerTexture);
        GUIStyle style = new GUIStyle()
        {
            font        = EditorStyles.boldFont,
            alignment   = TextAnchor.MiddleCenter,
            fixedHeight = 50,
            fontSize    = 25
        };
        GUILayout.Label(new GUIContent("Conversation Editor"), style);
        GUILayout.EndArea();
        #endregion End Header View

        #region Left Side View
        SideWidth = Screen.width / 3f;
        rect      = new Rect(0, headerHeight, SideWidth, Screen.height);
        GUI.DrawTexture(rect, leftTexture);
        GUILayout.BeginArea(rect);
        scrollPosOfConversations = EditorGUILayout.BeginScrollView(scrollPosOfConversations, GUILayout.Width(SideWidth), GUILayout.Height(Screen.height - 100f));
        foreach (var item in conversations)
        {
            if (item == selectedConversation)
            {
                Texture2D tex = new Texture2D(1, 1);
                tex.SetPixel(0, 0, Color.blue);
                tex.Apply();
                style.normal.background = tex;
                GUILayout.BeginHorizontal(style);
            }
            else
            {
                GUILayout.BeginHorizontal();
            }

            GUILayout.Label(item.ConversationName, normalStyle, GUILayout.Width((Screen.width / 3.0f) * 0.70f));
            if (GUILayout.Button("Edit"))
            {
                selectedConversation = item;
                CreateTreeStructure.AssignPositionToNodes(selectedConversation, nodeWidth, nodeHeight, nodeHorSpace, nodeVerSpace);
            }
            if (GUILayout.Button("delete"))
            {
                conversations.Remove(selectedConversation);
                string path = AssetDatabase.GetAssetPath(selectedConversation);
                AssetDatabase.DeleteAsset(path);
                selectedConversation = null;
            }
            GUILayout.EndHorizontal();
        }
        EditorGUILayout.EndScrollView();

        if (GUILayout.Button("Add New Conversation", GUILayout.Width(200f)))
        {
            AddConversation();
        }
        GUILayout.EndArea();
        #endregion End Left Side View

        #region Right Side View
        rect = new Rect(SideWidth, headerHeight, Screen.width - SideWidth - 10f, Screen.height - headerHeight - 30f);

        if (selectedConversation == null)
        {
            GUI.DrawTexture(rect, rightTexture);
        }
        else
        {
            GUILayout.BeginArea(rect);
            selectedTabInt = GUILayout.Toolbar(selectedTabInt, toolBars);
            EditorGUI.BeginChangeCheck();
            if (EditorGUI.EndChangeCheck())
            {
                scrollPosOfRightView = Vector2.zero;
            }

            if (selectedTabInt == 0)
            {
                GUI.DrawTexture(new Rect(0, 20f, rect.width, rect.height - headerHeight), selectedScreenTexture);
                ShowActors(rect);
            }
            else if (selectedTabInt == 1)
            {
                GUI.DrawTexture(new Rect(0, 20f, rect.width, rect.height - headerHeight), selectedScreenTexture);
                ShowBubbleTalks(rect);
            }
            else if (selectedTabInt == 2)
            {
                GUI.DrawTexture(new Rect(0, 20f, rect.width, rect.height - bottomHeight), selectedScreenTexture);
                if (selectedConversation.SpeechBubbles.Count > 0 && selectedConversation.ActorPrefabs.Count > 0)
                {
                    Event e = Event.current;
                    if (e.button == 1 && e.isMouse)
                    {
                        selectedDialogue = GetSelectedDialogue(e.mousePosition);
                        if (!isAddingDialogue && selectedDialogue != null)
                        {
                            RightClickMenuOfDialogues();
                        }
                    }

                    ShowDialogueScreen(rect);
                }
                else if (selectedConversation.SpeechBubbles.Count <= 0)
                {
                    GUILayout.Label("Add Speech Bubbles in the list", normalStyle);
                }
                else if (selectedConversation.ActorPrefabs.Count <= 0)
                {
                    GUILayout.Label("Add Actor Bubbles in the list", normalStyle);
                }
            }
            else if (selectedTabInt == 3)
            {
                GUI.DrawTexture(new Rect(0, 20f, rect.width, rect.height - headerHeight), selectedScreenTexture);
                ShowQuest(rect);
            }
            GUILayout.EndArea();
        }

        #endregion End Right Side View
    }