public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            var t = (DialogueOwner)target;

            if (t.dialogueCamera == null)
            {
                var d = t.gameObject.GetComponentInChildren <DialogueCamera>();
                if (d != null)
                {
                    if (GUILayout.Button("Set child dialogue camera"))
                    {
                        t.dialogueCamera = d;
                        EditorUtility.SetDirty(t);
                    }
                }
            }

            if (GUILayout.Button("Create new dialogue"))
            {
                var path = EditorUtility.SaveFilePanelInProject("Save location", "Dialogue" + DateTime.Now.ToFileTime(), "asset", "Save new dialogue object location");
                if (string.IsNullOrEmpty(path) == false)
                {
                    var asset = ScriptableObject.CreateInstance <Dialogue>();
//                    string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/New " + typeof(Dialogue).ToString() + ".asset");

                    AssetDatabase.CreateAsset(asset, path);
                    AssetDatabase.SaveAssets();
                    AssetDatabase.Refresh();

                    t.dialogue = AssetDatabase.LoadAssetAtPath <Dialogue>(path);
                    EditorUtility.SetDirty(t);

                    DialogueEditorWindow.Edit(t);
                }
            }

            if (GUILayout.Button("Edit dialogue"))
            {
                DialogueEditorWindow.Edit(t);
            }

            var trigger = t.gameObject.GetComponent <TriggerBase>();

            if (trigger == null)
            {
                GUILayout.Space(10);

                GUILayout.Label("You can add a trigger to set the use distance.");
                foreach (var type in ReflectionUtility.GetAllTypesThatImplement(typeof(TriggerBase)))
                {
                    var tempType = type;
                    if (GUILayout.Button("Add: " + tempType.Name))
                    {
                        t.gameObject.AddComponent(tempType);
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected override object DrawInternal(Rect rect)
        {
            foreach (var child in children)
            {
                child.Draw(ref rect);
            }

            rect.y += ReflectionDrawerStyles.singleLineHeight;
            if (GUI.Button(rect, "Edit"))
            {
                DialogueEditorWindow.Edit((Dialogue)value);
            }

            return(value);
        }
Exemplo n.º 3
0
        public override void UpdateIssue()
        {
            var dialogues = UnityEngine.Resources.FindObjectsOfTypeAll <Dialogue>();

            foreach (var dialogue in dialogues)
            {
                foreach (var node in dialogue.nodes)
                {
                    var v = node.Validate();
                    if (v.validationType != ValidationType.Valid)
                    {
                        var d = dialogue;
                        var n = node;
                        issues.Add(new GameRuleIssue(v.message, v.validationType == ValidationType.Warning ? MessageType.Warning : MessageType.Error, new GameRuleAction("Select node",
                                                                                                                                                                         () =>
                        {
                            DialogueEditorWindow.Edit(d);
                            DialogueEditorWindow.FocusOnNode(n);
                            DialogueEditorWindow.PingNode(n);
                        })));
                    }
                }
            }
        }