using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
[CustomEditor(typeof(DialogueTrigger))]
public class DialogueTriggerEditor : Editor
{
private SerializedProperty _conversations;
private void OnEnable()
{
_conversations = serializedObject.FindProperty("conversations");
}
public override void OnInspectorGUI()
{
//base.OnInspectorGUI();
serializedObject.Update();
_conversations.arraySize = EditorGUILayout.IntField("Conversations Size", _conversations.arraySize);
for (int x = 0; x < _conversations.arraySize; x++)
{
var conversation = _conversations.GetArrayElementAtIndex(x);
var conversationName = conversation.FindPropertyRelative("conversationName");
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(conversationName);
EditorGUI.indentLevel++;
var _dialogues = conversation.FindPropertyRelative("Dialogues");
_dialogues.arraySize = EditorGUILayout.IntField("Dialogues size", _dialogues.arraySize);
for (int i = 0; i < _dialogues.arraySize; i++)
{
var dialogue = _dialogues.GetArrayElementAtIndex(i);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(dialogue, new GUIContent("Dialogue " + i), true);
EditorGUI.indentLevel--;
}
if (_dialogues.arraySize > 0)
{
if (GUILayout.Button("Save Conversation"))
{
}
}
EditorGUI.indentLevel--;
EditorGUI.indentLevel--;
}
serializedObject.ApplyModifiedProperties();
}
}
It seems like the serializedObject contains old 3 dialogues with text names and sentences even if I set the conversations size to 0 and all dialogues also set in the inspector to 0 but still when using a break point on the line:
serializedObject.Update();
I see on the serializedObject that it contains the old dialogues. Either when running the game or in the editor I see the old dialogues. And then when running the game it's using this dialogues.
But I want that if I set the conversations size to 0 or the dialogues size to 0 to delete all dialogues sentences names all text.
Here is a screenshot showing when using a break point on it before the game is running: There are 3 dialogues names and sentences:
And this is a screenshot of the editor: Everything is empty the conversations size is set to 0. But still when running the game it's taking/getting the old dialogues from the serializedObject.
I'm not sure yet where this old 3 dialogues are kept. In the editor memory ?
Ok after a long search I found that the text of the dialogues names and sentences is stored for some reason inside the project scene file:
With my program that search inside files I could find it in the scene .unity file of my project.
Still I can't figure out what object or what script store it or call it or what and why make it show when running the game.
But at least I found where it stored. What next ? I have no clue.
After edited the file in notepad I found the area of the text:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1705786629}
- component: {fileID: 1705786630}
m_Layer: 0
m_Name: DialogueTrigger
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1705786629
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1705786628}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 104156395}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1705786630
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1705786628}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8a658bdd09c49324ba103199b05e0b88, type: 3}
m_Name:
m_EditorClassIdentifier:
conversations: []
dialogue:
- name: NAVI
sentences:
- Hey Hey, Someone is coming...
- Quick let's hide.
- name: PLAYER
sentences:
- I'm the player so....
- And I can't play now
- name: NEW MAN
sentences:
- Hello my friend
- I need help
- I lost my basket full of apples
- Please help me find it
- Your award will help you in your quest
dialogueNum: 0
But it's a small part of the file not sure if it's telling anything more.