Example #1
0
    void OnGUI()
    {
        EditorStyles.textField.wordWrap = true;
        GUI.enabled = !modalWindows.IsWindowOpen;

        if (Selection.activeGameObject == null)
        {
            return;
        }


        SpeechableCharacter personagem = (SpeechableCharacter)Selection.activeGameObject.GetComponent <SpeechableCharacter>();

        if (personagem != null)
        {
            OpenCharacterDialogEditor(personagem);
        }

        PistaItem pista = (PistaItem)Selection.activeGameObject.GetComponent <PistaItem>();

        if (pista != null)
        {
            OpenPistaDialogEditor(pista);
        }

        if (GUI.changed)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }

        BeginWindows();
        modalWindows.Draw();
        EndWindows();
    }
Example #2
0
    public void OpenPistaDialogEditor(PistaItem pista)
    {
        pista.speech           = (SpeechManager)EditorGUILayout.ObjectField("Speech Canvas", pista.speech, typeof(SpeechManager), true);
        pista.data.displayName = EditorGUILayout.TextField("Nome Display", pista.data.displayName);
        pista.data.itemId      = EditorGUILayout.TextField("ID do item", pista.data.itemId);

        EditorGUILayout.LabelField("Descrição do item");
        pista.data.itemDescription = EditorGUILayout.TextArea(pista.data.itemDescription, GUILayout.Height(50));

        string[] pistaKeys = pista.manager.textureManager.getPistaKeys();
        string[] posesKeys = pista.manager.textureManager.getPoseKeys();

        int imageValue = EditorGUILayout.Popup("Ícone pista", pista.manager.textureManager.getIndexByKeyPista(pista.data.image), pistaKeys);

        pista.data.image = pistaKeys[imageValue];
        GUI.DrawTexture(new Rect(10, 160, 100, 100), pista.manager.textureManager.pistas[imageValue].sprite.texture);
        GUILayout.Space(120);

        if (GUILayout.Button("Editar diálogo"))
        {
            //Modal para criar o diálogo
            var win = new ModalWindow(new Rect(30, 30, position.width - 60, position.height - 60), "CreateDialog", (w) =>
            {
                pista.data.dialogo.enabled = EditorGUILayout.Toggle("Destravado", pista.data.dialogo.enabled);
                if (GUILayout.Button("Adicionar Texto"))
                {
                    pista.data.dialogo.texts.Add(new TextData());
                }

                for (int j = 0; j < pista.data.dialogo.texts.Count; j++)
                {
                    GUILayout.Label("Texto " + j, EditorStyles.boldLabel);
                    pista.data.dialogo.texts[j].texto = EditorGUILayout.TextArea(pista.data.dialogo.texts[j].texto);
                    GUILayout.BeginHorizontal("box");
                    pista.data.dialogo.texts[j].owner = EditorGUILayout.TextField("Quem tá falando", pista.data.dialogo.texts[j].owner);

                    int index = pista.manager.textureManager.getIndexByKeyPose(pista.data.dialogo.texts[j].image);
                    if (index == -1)
                    {
                        index = 0;
                    }
                    int digValue = EditorGUILayout.Popup("Imagem", index, posesKeys);
                    pista.data.dialogo.texts[j].image = posesKeys[digValue];

                    GUILayout.EndHorizontal();
                    GUILayout.Space(10);
                }

                if (GUILayout.Button("Fechar"))
                {
                    w.Close();
                }

                GUI.DragWindow();
            });
            modalWindows.Add(win);
        }
    }
    public ScenarioData CreateScenarioData()
    {
        ScenarioData data = new ScenarioData();

        //Itera por todos os personagens
        foreach (Transform obj in personagens_folder.transform)
        {
            SpeechableCharacter character = obj.GetComponent <SpeechableCharacter>();
            data.characters.Add(character.data);
        }
        //Itera por todas as pistas
        foreach (Transform obj in pistas_folder.transform)
        {
            PistaItem pista = obj.GetComponent <PistaItem>();
            data.pistas.Add(pista.data);
        }
        //Itera por todos os exits
        foreach (Transform obj in exits_folder.transform)
        {
            data.exits.Add(obj.GetComponent <ExitPoint>().GetData());
        }

        return(data);
    }