private void DrawEntries() { scrollPos = EditorGUILayout.BeginScrollView(scrollPos); GUIStyle style = new GUIStyle(GUI.skin.button); style.normal.textColor = Color.red; for (int i = 0; i < database.database.Count; i++) { if (!string.IsNullOrEmpty(filterString) && !database.database[i].name.Contains(filterString)) { continue; } GUILayout.BeginHorizontal(); // string tmp = EditorGUILayout.DelayedTextField(database.database[i].name, GUILayout.Width(uuidWidth)); // if (!string.IsNullOrEmpty(tmp)) // database.database[i].name = tmp; GUILayout.Label(database.database[i].name, GUILayout.Width(uuidWidth)); database.database[i].character = (CharacterEntry)EditorGUILayout.ObjectField("", database.database[i].character, typeof(CharacterEntry), false, GUILayout.Width(characterWidth)); if (GUILayout.Button(poseList[database.database[i].pose], GUILayout.Width(poseWidth))) { GenericMenu menu = new GenericMenu(); SelectedPose selPose = new SelectedPose(); selPose.index = i; for (int p = 0; p < poseList.Length; p++) { selPose.pose = p; menu.AddItem(new GUIContent(poseList[p]), (p == database.database[i].pose), SetPose, selPose); } menu.ShowAsContext(); } database.database[i].text = EditorGUILayout.TextField(database.database[i].text, GUILayout.Width(textWidth)); GUILayout.Space(20); if (GUILayout.Button("X", style, GUILayout.Width(30))) { GUI.FocusControl(null); database.database.RemoveAt(i); i--; } GUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); }
/// <summary> /// Sets the pose of the character. /// </summary> /// <param name="selectedPose"></param> void SetPose(object selectedPose) { SelectedPose pose = (SelectedPose)selectedPose; hub.dialogueValues.actions[hub.selAction].values[pose.index] = pose.pose; }
/// <summary> /// Renders the characters and talking part. /// </summary> void CharacterStuff() { GUILayout.BeginArea(editRect); float fieldWidth = editRect.width * 0.25f; EditorGUIUtility.labelWidth = fieldWidth; GUILayout.Label("Set character and poses", EditorStyles.boldLabel); for (int j = 0; j < Utility.DIALOGUE_PLAYERS_COUNT + Utility.DIALOGUE_PLAYERS_OUTSIDE_COUNT; j++) { GUILayout.BeginArea(characterRects[j]); if (hub.dialogueValues.actions[hub.selAction].entries[j] != null) { GUILayout.Label(hub.dialogueValues.actions[hub.selAction].entries[j].entryName, EditorStyles.boldLabel); } else { GUILayout.Label("", EditorStyles.boldLabel); } GUILayout.Label("Character " + j); hub.dialogueValues.actions[hub.selAction].entries[j] = (PortraitEntry)EditorGUILayout.ObjectField("", hub.dialogueValues.actions[hub.selAction].entries[j], typeof(PortraitEntry), false, GUILayout.Width(fieldWidth - 8)); if (hub.dialogueValues.actions[hub.selAction].entries[j] == null) { hub.dialogueValues.actions[hub.selAction].values[j] = -1; GUILayout.EndArea(); continue; } if (hub.dialogueValues.actions[hub.selAction].values[j] == -1) { hub.dialogueValues.actions[hub.selAction].values[j] = 0; } if (GUILayout.Button(poseList[hub.dialogueValues.actions[hub.selAction].values[j]], GUILayout.Width(fieldWidth - 8))) { GenericMenu menu = new GenericMenu(); SelectedPose selPose = new SelectedPose(); selPose.index = j; for (int p = 0; p < poseList.Length; p++) { selPose.pose = p; menu.AddItem(new GUIContent(poseList[p]), (p == hub.dialogueValues.actions[hub.selAction].values[j]), SetPose, selPose); } menu.ShowAsContext(); } GUILayout.Space(20); if (j < Utility.DIALOGUE_PLAYERS_COUNT) { if (hub.dialogueValues.actions[hub.selAction].entries[j] == null) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(noCharacterSprite.sprite.texture); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(((PortraitEntry)hub.dialogueValues.actions[hub.selAction].entries[j]).poses[hub.dialogueValues.actions[hub.selAction].values[j]].texture, GUILayout.Width(80), GUILayout.Height(80)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } } GUILayout.EndArea(); } GUILayout.EndArea(); EditorGUIUtility.labelWidth = 100; }
/// <summary> /// Sets the pose of the character. /// </summary> /// <param name="selectedPose"></param> void SetPose(object selectedPose) { SelectedPose pose = (SelectedPose)selectedPose; database.database[pose.index].pose = pose.pose; }
/// <summary> /// Sets the pose of the character. /// </summary> /// <param name="selectedPose"></param> void SetPose(object selectedPose) { SelectedPose pose = (SelectedPose)selectedPose; dialogueValues.frames[selFrame].poses[pose.index] = pose.pose; }
/// <summary> /// Renders the characters and talking part. /// </summary> void CharacterStuff() { EditorGUIUtility.labelWidth = 70; float fieldWidth = d.rectChar[0].width - 8; for (int j = 0; j < 5; j++) { GUILayout.BeginArea(d.rectChar[j]); int index = indexList[j]; if (index == 4) { GUILayout.Label("Name: ", EditorStyles.boldLabel); talkName = EditorGUILayout.TextField("", talkName); GUILayout.EndArea(); continue; } if (dialogueValues.frames[selFrame].characters[index] != null) { GUILayout.Label(dialogueValues.frames[selFrame].characters[index].entryName, EditorStyles.boldLabel); } else { GUILayout.Label("Name: ", EditorStyles.boldLabel); } GUILayout.Label("Character"); dialogueValues.frames[selFrame].characters[index] = (CharacterEntry)EditorGUILayout.ObjectField("", dialogueValues.frames[selFrame].characters[index], typeof(CharacterEntry), false, GUILayout.Width(fieldWidth)); if (dialogueValues.frames[selFrame].characters[index] == null) { dialogueValues.frames[selFrame].poses[index] = -1; GUILayout.EndArea(); continue; } if (dialogueValues.frames[selFrame].poses[index] == -1) { dialogueValues.frames[selFrame].poses[index] = 0; } if (GUILayout.Button(poseList[dialogueValues.frames[selFrame].poses[index]], GUILayout.Width(fieldWidth))) { GenericMenu menu = new GenericMenu(); SelectedPose selPose = new SelectedPose(); selPose.index = index; for (int p = 0; p < poseList.Length; p++) { selPose.pose = p; menu.AddItem(new GUIContent(poseList[p]), (p == dialogueValues.frames[selFrame].poses[index]), SetPose, selPose); } menu.ShowAsContext(); } GUILayout.BeginHorizontal(); GUI.DrawTexture(faceRect, dialogueValues.frames[selFrame].characters[index].defaultColor.texture); GUILayout.FlexibleSpace(); GUILayout.Label(dialogueValues.frames[selFrame].characters[index].poses[dialogueValues.frames[selFrame].poses[index]].texture); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndArea(); } EditorGUIUtility.labelWidth = 100; }