Exemplo n.º 1
0
 public static void HandleUnityUIDialogueUI(UnityUIDialogueUI ui, DialogueSystemController dialogueManager)
 {
     if (ui == null) return;
     if (Tools.IsPrefab(ui.gameObject) && (ui.GetComponentInParent<Canvas>() == null)) {
         if (EditorUtility.DisplayDialog("Unity UI Dialogue UI", "A Unity UI Dialogue UI must be a child of a Canvas. Add a Canvas (if needed) and an instance of the dialogue UI to the Dialogue Manager?", "OK", "Cancel")) {
             SetupCanvas(ui, dialogueManager);
         } else {
             dialogueManager.displaySettings.dialogueUI = null;
         }
     }
 }
Exemplo n.º 2
0
 private static void SetupCanvas(UnityUIDialogueUI ui, DialogueSystemController dialogueManager)
 {
     if (FindObjectOfType<UnityEngine.EventSystems.EventSystem>() == null) {
         new GameObject("EventSystem", typeof(UnityEngine.EventSystems.EventSystem),
             typeof(UnityEngine.EventSystems.StandaloneInputModule),
             typeof(UnityEngine.EventSystems.TouchInputModule));
     }
     var canvas = dialogueManager.GetComponentInChildren<Canvas>();
     if (canvas == null) {
         var canvasObject = new GameObject("Canvas");
         canvasObject.layer = 5; // Built-in UI layer.
         canvasObject.AddComponent<Canvas>();
         canvasObject.AddComponent<UnityEngine.UI.CanvasScaler>();
         canvasObject.AddComponent<UnityEngine.UI.GraphicRaycaster>();
         canvas = canvasObject.GetComponent<Canvas>();
         canvas.renderMode = RenderMode.ScreenSpaceOverlay;
         canvasObject.transform.SetParent(dialogueManager.transform);
     }
     var uiInstance = Instantiate(ui) as UnityUIDialogueUI;
     uiInstance.transform.SetParent(canvas.transform, false);
     dialogueManager.displaySettings.dialogueUI = uiInstance.gameObject;
 }
		private void OnEnable() {
			dialogueSystemController = target as DialogueSystemController;
		}
Exemplo n.º 4
0
		private void DrawSelectDBStage() {
			EditorGUILayout.LabelField("Select Dialogue Database", EditorStyles.boldLabel);
			EditorWindowTools.StartIndentedSection();
			EditorGUILayout.HelpBox("Assign the dialogue database that the NPC will use for conversations and barks.", MessageType.Info);
			if (dialogueManager == null) {
				dialogueManager = FindObjectOfType<DialogueSystemController>();
			}
			if (database == null && dialogueManager != null) {
				database = dialogueManager.initialDatabase;
			}
			DialogueDatabase newDatabase = EditorGUILayout.ObjectField("Dialogue Database", database, typeof(DialogueDatabase), true) as DialogueDatabase;
			if (newDatabase != database) {
				database = newDatabase;
				CreateConversationList(database);
			}
			if (dialogueManager != null && database != null && dialogueManager.initialDatabase != database) {
				EditorGUILayout.HelpBox("This is not the initial database assigned to the Dialogue Manager. Remember to load this database at runtime before using the NPC. You can use the Extra Databases component or DialogueManager.AddDatabase() in script. Also make sure the internal IDs are unique across databases. You can use the Unique ID Tool to do this.", MessageType.Warning);
			}
			EditorWindowTools.EndIndentedSection();
			DrawNavigationButtons(true, (database != null), false);
		}
Exemplo n.º 5
0
 private static DialogueSystemController FindOrCreateInstance()
 {
     if (instance == null) {
         instance = GameObject.FindObjectOfType(typeof(DialogueSystemController)) as DialogueSystemController;
         if (instance == null) {
             if (DialogueSystemController.applicationIsQuitting) {
                 instance = null;
             } else {
                 instance = new GameObject("Dialogue Manager").AddComponent<DialogueSystemController>();
             }
         }
     }
     return instance;
 }