예제 #1
0
 public DialogOptionResponseSignal(DialogOptionData data, List <UnityEvent> events, List <Transform> transforms, UnityEvent exitEvent = null)
 {
     _data       = data;
     _events     = events;
     _transforms = transforms;
     _exitEvent  = exitEvent;
 }
예제 #2
0
        public DialogOptionData(DialogOptionData data)
        {
            id       = data.id;
            name     = data.name;
            haveExit = data.haveExit;

            for (int i = 0; i < data.options.Count; i++)
            {
                options.Add(data.options[i]);
            }
        }
        public DialogOptionData Handle(string id)
        {
            DialogOptionData databaseData = _database.data.Find(data => data.id == id);
            DialogOptionData runtimeData  = null;

            if (databaseData != null)
            {
                runtimeData = new DialogOptionData(databaseData);
            }

            return(runtimeData);
        }
        private void DrawCreateTab()
        {
            DrawHeaderTab("Create Dialog Option");
            EditorGUILayout.BeginVertical("Button");
            GUILayout.Label("Dialog Name", EditorStyles.largeLabel);
            _newData.name = EditorGUILayout.TextField(_newData.name);
            GUILayout.Label("Have an exit option?", EditorStyles.largeLabel);
            _newDataHaveExit = EditorGUILayout.Popup(_newDataHaveExit, _exitPopup.ToArray());

            if (_oldNewDataHaveExit != _newDataHaveExit)
            {
                _oldNewDataHaveExit = _newDataHaveExit;
                _newData.haveExit   = Convert.ToBoolean(_newDataHaveExit);
            }

            if (_oldName != _newData.name)
            {
                _oldName    = _newData.name;
                _newData.id = $"dialog_option_{_newData.name}_{NanoId.Generate(8)}";
            }

            GUILayout.Label("Dialog ID", EditorStyles.largeLabel);
            GUILayout.Label(_newData.id, EditorStyles.largeLabel);
            EditorGUILayout.Space(5);
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Button");
            GUILayout.Label("Dialog Options", EditorStyles.largeLabel);

            if (_newData.options.Count < _database.maximumOption)
            {
                if (GUILayout.Button("Add option", EditorStyles.toolbarButton))
                {
                    _newData.options.Add(new OptionData());
                }
            }
            else
            {
                EditorGUILayout.HelpBox("You reached the maximum capacity of options", MessageType.Info);
            }


            for (int i = 0; i < _newData.options.Count; i++)
            {
                GUILayout.Label($"Option#{i}: {_newData.options[i].value}", EditorStyles.largeLabel);
                GUILayout.Label("Override exit option");
                _newData.options[i].overrideExit = EditorGUILayout.Toggle(_newData.options[i].overrideExit);
                _newData.options[i].value        = EditorGUILayout.TextArea(_newData.options[i].value);

                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button($"Clear {_newData.options[i].value}", EditorStyles.toolbarButton))
                {
                    _newData.options[i].value = "";
                }

                if (GUILayout.Button($"Remove {_newData.options[i].value}", EditorStyles.toolbarButton))
                {
                    _newData.options.RemoveAt(i);
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Space(5);
            EditorGUILayout.EndVertical();

            if (GUILayout.Button($"Add {_newData.name}"))
            {
                _database.data.Add(_newData);
                _newData = new DialogOptionData();
                EditorUtility.SetDirty(_database);
                serializedObject.ApplyModifiedProperties();
            }
            EditorGUILayout.Space(5);
        }