Example #1
0
 private void OnEnable()
 {
     Debug.Log("CExamTool.OnEnable");
     if (null == mDialogueList)
     {
         mDialogueList            = new CDialogueInfoList();
         mDialogueList.mDialogues = new List <CDialogueInfo>();
     }
 }
Example #2
0
    private void OnGUI()
    {
        int ti = 0;

        EditorGUILayout.BeginHorizontal();

        if (true == GUILayout.Button("Test", GUILayout.Width(60), GUILayout.Height(50)))
        {
            CDialogueInfo tDialogueInfo = null;
            tDialogueInfo           = new CDialogueInfo();
            tDialogueInfo.mId       = mCurCount;
            tDialogueInfo.mDialogue = mCurCount.ToString() + "번째 대화입니다.";

            mDialogueList.mDialogues.Add(tDialogueInfo);
            //mDialogueInfoList.Add(tDialogueInfo);

            mCurCount++;
        }

        GUILayout.Space(50);

        if (true == GUILayout.Button("New", GUILayout.Width(60), GUILayout.Height(50)))
        {
            for (ti = 0; ti < mDialogueList.mDialogues.Count; ti++)
            {
                mDialogueList.mDialogues[ti] = null;
            }
            mDialogueList.mDialogues.Clear();

            EditorApplication.update();
        }

        if (true == GUILayout.Button("Load", GUILayout.Width(60), GUILayout.Height(50)))
        {
            //LoadTestFromFile("Assets/Resources/dialogue_list.xml");

            using (StreamReader reader = new StreamReader("Assets/Resources/dialogue_list_json.json"))
            {
                string data = reader.ReadToEnd();

                mDialogueList.mDialogues.Clear();
                mDialogueList.mDialogues = null;
                mDialogueList            = null;

                mDialogueList = JsonUtility.FromJson <CDialogueInfoList>(data);
            }



            //EditorApplication.update();
        }


        if (true == GUILayout.Button("Save", GUILayout.Width(60), GUILayout.Height(50)))
        {
            //SaveTestToFile("Assets/Resources/dialogue_list.xml");
            using (StreamWriter writer = new StreamWriter("Assets/Resources/dialogue_list_json.json"))
            {
                Debug.Log(JsonUtility.ToJson(mDialogueList));
                writer.Write(JsonUtility.ToJson(mDialogueList));
            }
            AssetDatabase.Refresh();
        }

        EditorGUILayout.EndHorizontal();



        GUILayout.Space(5);



        EditorGUILayout.BeginVertical();

        EditorGUILayout.LabelField("dialogue", EditorStyles.helpBox);

        for (ti = 0; ti < mDialogueList.mDialogues.Count; ti++)
        {
            EditorGUILayout.LabelField(mDialogueList.mDialogues[ti].mId.ToString(), EditorStyles.helpBox);

            mDialogueList.mDialogues[ti].mDialogue = EditorGUILayout.TextField(mDialogueList.mDialogues[ti].mDialogue);
        }


        EditorGUILayout.EndVertical();
    }
 private void LoadDialogueData()
 {
     TextAsset tTextAsset = Resources.Load<TextAsset>("Dialogue/dialogue_list_json");
     mDialogueList = JsonUtility.FromJson<CDialogueInfoList>(tTextAsset.text);
 }
Example #4
0
    public void CreateMy()
    {
        string dialogueData = Resources.Load <TextAsset>("dialogue_list_json").text;

        mDialogueList = JsonUtility.FromJson <CDialogueInfoList>(dialogueData);
    }