notebook实装功能,galgame继续,一些bug修复
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 719967629852ca34d9aa1f9d05872275
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf4473abb00e19640a1e4c970f4732ed
|
||||
@@ -0,0 +1,233 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(ScriptableObject), true)]
|
||||
public class ingame_galgame_so_Editor : Editor
|
||||
{
|
||||
private SerializedProperty triggerMethodProp;
|
||||
private SerializedProperty timelineStandardProp;
|
||||
private SerializedProperty dialogueTypeProp;
|
||||
private SerializedProperty speakersDataSOProp;
|
||||
private SerializedProperty dialogueListProp;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (target != null && target.GetType().Name == "ingame_galgame_so")
|
||||
{
|
||||
triggerMethodProp = serializedObject.FindProperty("triggerMethod");
|
||||
timelineStandardProp = serializedObject.FindProperty("timelineStandard");
|
||||
dialogueTypeProp = serializedObject.FindProperty("dialogueType");
|
||||
speakersDataSOProp = serializedObject.FindProperty("speakersDataSO");
|
||||
dialogueListProp = serializedObject.FindProperty("dialogueList");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (target == null || target.GetType().Name != "ingame_galgame_so")
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
return;
|
||||
}
|
||||
|
||||
serializedObject.Update();
|
||||
EnsureProperties();
|
||||
|
||||
if (dialogueTypeProp != null) EditorGUILayout.PropertyField(dialogueTypeProp);
|
||||
if (triggerMethodProp != null) EditorGUILayout.PropertyField(triggerMethodProp);
|
||||
if (timelineStandardProp != null) EditorGUILayout.PropertyField(timelineStandardProp);
|
||||
if (speakersDataSOProp != null) EditorGUILayout.PropertyField(speakersDataSOProp);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Dialogue List", EditorStyles.boldLabel);
|
||||
|
||||
// speaker dropdown data
|
||||
string[] speakerNames = null;
|
||||
Object speakersObj = speakersDataSOProp != null ? speakersDataSOProp.objectReferenceValue : null;
|
||||
|
||||
if (speakersObj != null)
|
||||
{
|
||||
var speakersSO = new SerializedObject(speakersObj);
|
||||
var speakersList = speakersSO.FindProperty("speakers");
|
||||
|
||||
if (speakersList != null && speakersList.isArray)
|
||||
{
|
||||
int c = speakersList.arraySize;
|
||||
|
||||
speakerNames = new string[c + 1];
|
||||
speakerNames[0] = "(None)";
|
||||
|
||||
for (int i = 0; i < c; i++)
|
||||
{
|
||||
var e = speakersList.GetArrayElementAtIndex(i);
|
||||
var nameProp = e.FindPropertyRelative("spkrName");
|
||||
|
||||
speakerNames[i + 1] =
|
||||
nameProp != null ? nameProp.stringValue : $"Speaker {i}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dialogueListProp == null)
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
return;
|
||||
}
|
||||
|
||||
// ===== DRAW ELEMENTS =====
|
||||
|
||||
for (int i = 0; i < dialogueListProp.arraySize; i++)
|
||||
{
|
||||
var elemProp = dialogueListProp.GetArrayElementAtIndex(i);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
elemProp.isExpanded =
|
||||
EditorGUILayout.Foldout(elemProp.isExpanded, $"Element {i}", true);
|
||||
|
||||
// Move up
|
||||
GUI.enabled = i > 0;
|
||||
if (GUILayout.Button("Up", GUILayout.Width(32)))
|
||||
{
|
||||
dialogueListProp.MoveArrayElement(i, i - 1);
|
||||
}
|
||||
|
||||
// Move down
|
||||
GUI.enabled = i < dialogueListProp.arraySize - 1;
|
||||
if (GUILayout.Button("Down", GUILayout.Width(42)))
|
||||
{
|
||||
dialogueListProp.MoveArrayElement(i, i + 1);
|
||||
}
|
||||
|
||||
GUI.enabled = true;
|
||||
|
||||
// Duplicate
|
||||
if (GUILayout.Button("D", GUILayout.Width(25)))
|
||||
{
|
||||
dialogueListProp.InsertArrayElementAtIndex(i);
|
||||
}
|
||||
|
||||
// Delete
|
||||
GUI.color = Color.red;
|
||||
|
||||
if (GUILayout.Button("X", GUILayout.Width(25)))
|
||||
{
|
||||
if (EditorUtility.DisplayDialog(
|
||||
"Delete Element",
|
||||
"Are you sure you want to delete this element?",
|
||||
"Delete",
|
||||
"Cancel"))
|
||||
{
|
||||
dialogueListProp.DeleteArrayElementAtIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GUI.color = Color.white;
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (!elemProp.isExpanded)
|
||||
continue;
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
var positionTagProp = elemProp.FindPropertyRelative("positionTag");
|
||||
if (positionTagProp != null)
|
||||
{
|
||||
EditorGUILayout.PropertyField(positionTagProp);
|
||||
}
|
||||
else
|
||||
{
|
||||
var customPosProp = elemProp.FindPropertyRelative("customPositions");
|
||||
if (customPosProp != null) EditorGUILayout.PropertyField(customPosProp, true);
|
||||
}
|
||||
|
||||
var textListProp = elemProp.FindPropertyRelative("textList");
|
||||
|
||||
if (textListProp != null)
|
||||
{
|
||||
EditorGUILayout.LabelField("Texts", EditorStyles.boldLabel);
|
||||
|
||||
for (int j = 0; j < textListProp.arraySize; j++)
|
||||
{
|
||||
var textProp = textListProp.GetArrayElementAtIndex(j);
|
||||
if (textProp == null)
|
||||
continue;
|
||||
|
||||
textProp.isExpanded =
|
||||
EditorGUILayout.Foldout(textProp.isExpanded, $"Text {j}");
|
||||
|
||||
if (!textProp.isExpanded)
|
||||
continue;
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
var contentProp = textProp.FindPropertyRelative("content");
|
||||
var textNumberProp = textProp.FindPropertyRelative("textNumber");
|
||||
var senderIndexProp = textProp.FindPropertyRelative("senderIndex");
|
||||
var imagePosProp = textProp.FindPropertyRelative("imagePos");
|
||||
var appearTimeProp = textProp.FindPropertyRelative("appearTime");
|
||||
var durationProp = textProp.FindPropertyRelative("duration");
|
||||
var stepMethodProp = textProp.FindPropertyRelative("stepMethod");
|
||||
var timeActionProp = textProp.FindPropertyRelative("timeAction");
|
||||
var slowMotionProp = textProp.FindPropertyRelative("slowMotionScale");
|
||||
var endActionProp = textProp.FindPropertyRelative("endAction");
|
||||
|
||||
EditorGUILayout.PropertyField(contentProp);
|
||||
EditorGUILayout.PropertyField(textNumberProp);
|
||||
|
||||
if (speakerNames != null)
|
||||
{
|
||||
int current =
|
||||
Mathf.Clamp(senderIndexProp.intValue + 1, 0, speakerNames.Length - 1);
|
||||
|
||||
int chosen =
|
||||
EditorGUILayout.Popup("Sender", current, speakerNames);
|
||||
|
||||
senderIndexProp.intValue =
|
||||
Mathf.Max(-1, chosen - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(senderIndexProp);
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(imagePosProp);
|
||||
EditorGUILayout.PropertyField(appearTimeProp);
|
||||
EditorGUILayout.PropertyField(durationProp);
|
||||
EditorGUILayout.PropertyField(stepMethodProp);
|
||||
EditorGUILayout.PropertyField(timeActionProp);
|
||||
EditorGUILayout.PropertyField(slowMotionProp);
|
||||
EditorGUILayout.PropertyField(endActionProp);
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
if (GUILayout.Button("Add Dialogue Element"))
|
||||
{
|
||||
dialogueListProp.InsertArrayElementAtIndex(dialogueListProp.arraySize);
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void EnsureProperties()
|
||||
{
|
||||
if (triggerMethodProp == null) triggerMethodProp = serializedObject.FindProperty("triggerMethod");
|
||||
if (timelineStandardProp == null) timelineStandardProp = serializedObject.FindProperty("timelineStandard");
|
||||
if (dialogueTypeProp == null) dialogueTypeProp = serializedObject.FindProperty("dialogueType");
|
||||
if (speakersDataSOProp == null) speakersDataSOProp = serializedObject.FindProperty("speakersDataSO");
|
||||
if (dialogueListProp == null) dialogueListProp = serializedObject.FindProperty("dialogueList");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0eb6197bfc1d20247a4a26b7523e5342
|
||||
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[System.Serializable]
|
||||
public class Speaker
|
||||
{
|
||||
public speakerType spkrType = speakerType.systemLyrics;
|
||||
public int spkrID;
|
||||
public string spkrName;
|
||||
public Color spkr_themeColor;
|
||||
|
||||
[TextArea(3, 10)]
|
||||
public string spkrDescription;
|
||||
|
||||
public Sprite spkrSprite;
|
||||
}
|
||||
|
||||
public enum speakerType{
|
||||
systemBG,
|
||||
systemLyrics,
|
||||
character
|
||||
}
|
||||
|
||||
[CreateAssetMenu(fileName = "NewSpeakerSO", menuName = "Galgame/speakerSO")]
|
||||
public class galgame_speakers_so : ScriptableObject
|
||||
{
|
||||
[Header("Speakers List")]
|
||||
public List<Speaker> speakers = new List<Speaker>();
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a26d4e8f67913948b9e708170c6c51f
|
||||
@@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class gameplayGalgame : MonoBehaviour
|
||||
{
|
||||
[Header("enable galgame so")]
|
||||
public bool enableGalgame = false;
|
||||
public bool enableLyricsSO = true;
|
||||
[Header("gal so")]
|
||||
public ingame_galgame_so golSO;
|
||||
[Header("prefabs")]
|
||||
public GameObject galgamePrefab;
|
||||
public GameObject where_to_put;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9aacd8c1a046cf4d92dea52345397e7
|
||||
@@ -4,24 +4,6 @@ using System.Collections.Generic;
|
||||
[CreateAssetMenu(fileName = "NewGalSO", menuName = "Galgame/galSO")]
|
||||
public class ingame_galgame_so : ScriptableObject
|
||||
{
|
||||
[System.Serializable]
|
||||
public class CharacterInfo
|
||||
{
|
||||
public string characterName;
|
||||
public Sprite characterImage;
|
||||
public Color themeColor;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class DialogueElement
|
||||
{
|
||||
[Header("位置配置")]
|
||||
public List<Vector2> customPositions; // 自定义位置列表
|
||||
|
||||
[Header("文本内容配置")]
|
||||
public List<DialogueText> textList; // 文字列表
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class DialogueText
|
||||
{
|
||||
@@ -31,9 +13,10 @@ public class ingame_galgame_so : ScriptableObject
|
||||
|
||||
[Tooltip("队列中第几个文本")]
|
||||
public int textNumber; // 队列中第几个文本
|
||||
[Tooltip("请填写characterList中的Character Name(不区分大小写)")]
|
||||
public string sender; // 文本发出者角色名
|
||||
|
||||
|
||||
[Tooltip("从 speakersDataSO 中选择发言者")]
|
||||
public int senderIndex = -1; // 改为索引,通过下拉选择
|
||||
|
||||
public enum ImagePosition { Left, Right }
|
||||
[Tooltip("对象图片左右位置")]
|
||||
public ImagePosition imagePos; // 对象图片左右位置
|
||||
@@ -48,9 +31,9 @@ public class ingame_galgame_so : ScriptableObject
|
||||
public StepMethod stepMethod; // 文本步进方法
|
||||
|
||||
public enum TimeAction { None, SlowMotion, Pause }
|
||||
[Tooltip("文本出现时动作")]
|
||||
[Tooltip("文本出现时动作:无/慢动作/暂停")]
|
||||
public TimeAction timeAction; // 文本出现时动作
|
||||
|
||||
|
||||
[Tooltip("文本播放期间时间流速,0为暂停")]
|
||||
[Range(0f, 1f)]
|
||||
public float slowMotionScale = 0.5f; // 慢动作允许TimeScale设置值
|
||||
@@ -60,15 +43,35 @@ public class ingame_galgame_so : ScriptableObject
|
||||
public EndAction endAction; // 文本结束动作
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class DialogueElement
|
||||
{
|
||||
public enum PositionTag { Default, Left, Right, Upper, Down, Center }
|
||||
|
||||
[Header("位置配置")]
|
||||
public PositionTag positionTag;
|
||||
[HideInInspector]
|
||||
public List<Vector2> customPositions;
|
||||
|
||||
[Header("文本内容配置")]
|
||||
public List<DialogueText> textList; // 文字列表
|
||||
}
|
||||
|
||||
public enum TimelineBase { MusicTime, SceneStartTime, CustomTimer }
|
||||
public enum TriggerMethod { CodeTrigger, TimerTrigger, MixedTrigger }
|
||||
public enum DialogueType { Galgame, Lyrics }
|
||||
|
||||
[Header("全局配置")]
|
||||
[Tooltip("对话类型")]
|
||||
public DialogueType dialogueType;
|
||||
[Tooltip("触发方式")]
|
||||
public TriggerMethod triggerMethod;
|
||||
[Tooltip("时间线基准")]
|
||||
public TimelineBase timelineStandard;
|
||||
|
||||
public List<CharacterInfo> characterList = new List<CharacterInfo>();
|
||||
[Header("角色数据")]
|
||||
[Tooltip("引用 Speaker 配置 ScriptableObject")]
|
||||
public galgame_speakers_so speakersDataSO;
|
||||
|
||||
public List<DialogueElement> dialogueList = new List<DialogueElement>();
|
||||
}
|
||||
|
||||
@@ -12,18 +12,43 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: e7076655dfac6d34eb9ad82445b9962c, type: 3}
|
||||
m_Name: opGalSO
|
||||
m_EditorClassIdentifier:
|
||||
dialogueType: 0
|
||||
triggerMethod: 0
|
||||
timelineStandard: 0
|
||||
characterList:
|
||||
- characterName: Sonia
|
||||
characterImage: {fileID: 0}
|
||||
themeColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
speakersDataSO: {fileID: 11400000, guid: 8e500b367b7861f44897e5396b1989ce, type: 2}
|
||||
dialogueList:
|
||||
- customPositions:
|
||||
- {x: 0, y: 0}
|
||||
- positionTag: 0
|
||||
customPositions: []
|
||||
textList:
|
||||
- content: "\u7535\u68CD\u7B11\u4F20\u4E4B\u8E29\u8E29\u80CC"
|
||||
textNumber: 1
|
||||
sender: Sonia
|
||||
senderIndex: 0
|
||||
imagePos: 0
|
||||
appearTime: 0
|
||||
duration: 0
|
||||
stepMethod: 1
|
||||
timeAction: 0
|
||||
slowMotionScale: 0
|
||||
endAction: 0
|
||||
- positionTag: 0
|
||||
customPositions: []
|
||||
textList:
|
||||
- content: "\u7535\u68CD\u7B11\u4F20\u4E4B\u8E29\u8E29\u80CC"
|
||||
textNumber: 1
|
||||
senderIndex: 0
|
||||
imagePos: 0
|
||||
appearTime: 0
|
||||
duration: 0
|
||||
stepMethod: 0
|
||||
timeAction: 0
|
||||
slowMotionScale: 0
|
||||
endAction: 0
|
||||
- positionTag: 0
|
||||
customPositions: []
|
||||
textList:
|
||||
- content: "\u7535\u68CD\u7B11\u4F20\u4E4B\u8E29\u8E29\u80CC"
|
||||
textNumber: 1
|
||||
senderIndex: 0
|
||||
imagePos: 0
|
||||
appearTime: 0
|
||||
duration: 0
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1a26d4e8f67913948b9e708170c6c51f, type: 3}
|
||||
m_Name: spkrs
|
||||
m_EditorClassIdentifier:
|
||||
speakers:
|
||||
- spkrType: 0
|
||||
spkrID: 30000
|
||||
spkrName: SystemBG
|
||||
spkr_themeColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
spkrDescription: "\u7CFB\u7EDF\u65C1\u767D"
|
||||
spkrSprite: {fileID: 0}
|
||||
- spkrType: 1
|
||||
spkrID: 30001
|
||||
spkrName: SystemLyrics
|
||||
spkr_themeColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
spkrDescription: "\u7CFB\u7EDF\u6B4C\u8BCD"
|
||||
spkrSprite: {fileID: 0}
|
||||
- spkrType: 2
|
||||
spkrID: 30101
|
||||
spkrName: Sonia
|
||||
spkr_themeColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
spkrDescription: "\u89D2\u8272\u7D22\u5C3C\u5A05"
|
||||
spkrSprite: {fileID: 0}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e500b367b7861f44897e5396b1989ce
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user