功能批量实现 优化 服务端 新浮动小游戏框架 新界面UI

This commit is contained in:
FloatGaming
2026-04-24 13:20:16 +08:00
parent e0bc0bbf08
commit 5eec879582
257 changed files with 38481 additions and 1288 deletions
@@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnityEngine;
namespace EasyChart
@@ -506,18 +508,8 @@ namespace EasyChart
// Try Newtonsoft.Json first
try
{
var jsonConvertType = Type.GetType("Newtonsoft.Json.JsonConvert, Newtonsoft.Json")
?? Type.GetType("Newtonsoft.Json.JsonConvert, Unity.Newtonsoft.Json");
if (jsonConvertType != null)
{
var deserialize = jsonConvertType.GetMethod("DeserializeObject", new[] { typeof(string), typeof(Type) });
if (deserialize != null)
{
var obj = deserialize.Invoke(null, new object[] { json, typeof(ChartFeed) });
feed = obj as ChartFeed;
if (feed != null) return true;
}
}
feed = JsonConvert.DeserializeObject<ChartFeed>(json);
if (feed != null) return true;
}
catch
{
@@ -590,27 +582,14 @@ namespace EasyChart
try
{
var jObjectType = Type.GetType("Newtonsoft.Json.Linq.JObject, Newtonsoft.Json")
?? Type.GetType("Newtonsoft.Json.Linq.JObject, Unity.Newtonsoft.Json");
var jArrayType = Type.GetType("Newtonsoft.Json.Linq.JArray, Newtonsoft.Json")
?? Type.GetType("Newtonsoft.Json.Linq.JArray, Unity.Newtonsoft.Json");
if (jObjectType == null || jArrayType == null) return false;
var parse = jObjectType.GetMethod("Parse", new[] { typeof(string) });
if (parse == null) return false;
var root = parse.Invoke(null, new object[] { json });
if (root == null) return false;
JObject root = JObject.Parse(json);
feed = new ChartFeed();
var itemProp = jObjectType.GetProperty("Item", new[] { typeof(string) });
if (itemProp == null) return false;
string ReadString(object obj, string key)
string ReadString(JToken obj, string key)
{
if (obj == null) return null;
var token = itemProp.GetValue(obj, new object[] { key });
var token = obj[key];
if (token == null) return null;
var s = token.ToString();
if (string.IsNullOrEmpty(s)) return null;
@@ -618,7 +597,7 @@ namespace EasyChart
return s;
}
float ReadFloat(object obj, string key, float defaultValue = 0f)
float ReadFloat(JToken obj, string key, float defaultValue = 0f)
{
var s = ReadString(obj, key);
if (string.IsNullOrEmpty(s)) return defaultValue;
@@ -626,7 +605,7 @@ namespace EasyChart
return defaultValue;
}
bool ReadBool(object obj, string key, bool defaultValue = false)
bool ReadBool(JToken obj, string key, bool defaultValue = false)
{
var s = ReadString(obj, key);
if (string.IsNullOrEmpty(s)) return defaultValue;
@@ -634,10 +613,10 @@ namespace EasyChart
return defaultValue;
}
object GetToken(object obj, string key)
JToken GetToken(JToken obj, string key)
{
if (obj == null) return null;
return itemProp.GetValue(obj, new object[] { key });
return obj[key];
}
feed.chartId = ReadString(root, "chartId");
@@ -645,10 +624,10 @@ namespace EasyChart
// Axes
var axesToken = GetToken(root, "axes");
if (axesToken != null && jArrayType.IsInstanceOfType(axesToken))
if (axesToken is JArray axesArray)
{
var axes = new List<AxisFeed>();
foreach (var axisObj in (System.Collections.IEnumerable)axesToken)
foreach (var axisObj in axesArray)
{
if (axisObj == null) continue;
@@ -657,10 +636,10 @@ namespace EasyChart
var labelsToken = GetToken(axisObj, "labels");
string[] labels = null;
if (labelsToken != null && jArrayType.IsInstanceOfType(labelsToken))
if (labelsToken is JArray labelsArray)
{
var list = new List<string>();
foreach (var l in (System.Collections.IEnumerable)labelsToken)
foreach (var l in labelsArray)
{
if (l == null) continue;
var s = l.ToString();
@@ -677,10 +656,10 @@ namespace EasyChart
// Series
var seriesToken = GetToken(root, "series");
if (seriesToken != null && jArrayType.IsInstanceOfType(seriesToken))
if (seriesToken is JArray seriesArray)
{
var series = new List<SerieFeed>();
foreach (var serieObj in (System.Collections.IEnumerable)seriesToken)
foreach (var serieObj in seriesArray)
{
if (serieObj == null) continue;
@@ -699,12 +678,11 @@ namespace EasyChart
}
var datasToken = GetToken(serieObj, "datas");
if (datasToken != null && jArrayType.IsInstanceOfType(datasToken))
if (datasToken is JArray datasArray)
{
var datas = new List<DataFeed>();
object first = null;
foreach (var tmp in (System.Collections.IEnumerable)datasToken) { first = tmp; break; }
JToken first = datasArray.Count > 0 ? datasArray[0] : null;
if (first != null)
{
@@ -716,7 +694,7 @@ namespace EasyChart
{
// Values mode: datas: [1,2,3]
int dataIdx = 0;
foreach (var vToken in (System.Collections.IEnumerable)datasToken)
foreach (var vToken in datasArray)
{
if (vToken == null) { dataIdx++; continue; }
var vs = vToken.ToString();
@@ -728,7 +706,7 @@ namespace EasyChart
else if (firstIsArray)
{
// Tuple mode: datas: [[x,value], [x,value]] or [[x,y,value], ...]
foreach (var tupleToken in (System.Collections.IEnumerable)datasToken)
foreach (var tupleToken in datasArray)
{
if (tupleToken == null) continue;
var tupleText = tupleToken.ToString();
@@ -756,7 +734,7 @@ namespace EasyChart
else
{
// Standard/Full object mode
foreach (var dpObj in (System.Collections.IEnumerable)datasToken)
foreach (var dpObj in datasArray)
{
if (dpObj == null) continue;
var df = new DataFeed();
@@ -11,8 +11,22 @@ namespace EasyChart
get
{
if (s_isInstalled.HasValue) return s_isInstalled.Value;
var t = Type.GetType("EasyChart.Pro.EasyChartProBootstrap, EasyChart.Pro.Runtime");
s_isInstalled = t != null;
const string bootstrapTypeName = "EasyChart.Pro.EasyChartProBootstrap";
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
for (int i = 0; i < assemblies.Length; i++)
{
var assembly = assemblies[i];
if (assembly == null) continue;
var type = assembly.GetType(bootstrapTypeName, false);
if (type != null)
{
s_isInstalled = true;
return true;
}
}
s_isInstalled = false;
return s_isInstalled.Value;
}
}
+7 -2
View File
@@ -1638,7 +1638,7 @@ MonoBehaviour:
m_HandleRect: {fileID: 4343397997900734583}
m_Direction: 0
m_Value: 0
m_Size: 0.76151
m_Size: 0.76151013
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
@@ -1903,6 +1903,7 @@ MonoBehaviour:
- {fileID: 8201488678309066968}
editor_mailSO_Path: Assets/Resources/so/mail_so
runtime_mailSO_Path: so/mail_so
fetchMailsFromServer: 1
noticeSlotPrefab: {fileID: 5145544763127460675, guid: ea0f9a1959d19f647a3d75c45eb8606d, type: 3}
content_Notice_Slot: {fileID: 81963322720770975}
rewardSlotPrefab: {fileID: 7323784534273059606, guid: 8b93136fa224c0c4f8a6edc695ef4e2f, type: 3}
@@ -4239,7 +4240,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 353246841395789512}
m_HandleRect: {fileID: 705593826504867674}
m_Direction: 2
m_Value: 1
m_Value: 0
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
@@ -5473,6 +5474,10 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6083898120683566647, guid: ea0f9a1959d19f647a3d75c45eb8606d, type: 3}
propertyPath: m_AnchoredPosition.y
value: -6.1293945
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
+9 -9
View File
@@ -96,12 +96,12 @@ MonoBehaviour:
damageMultiplierGreat: 1
damageMultiplierPerfect: 1.1
missHpLossBase: 10
ally_currentEXP: 200
ally_growthUnlockedTierIndex: 1
ally_autoBreakthroughEnabled: 0
ally_battleDeployCount: 12
ally_finishCount: 12
ally_mvpCount: 7
ally_currentEXP: 520
ally_growthUnlockedTierIndex: 2
ally_autoBreakthroughEnabled: 1
ally_battleDeployCount: 0
ally_finishCount: 0
ally_mvpCount: 0
ally_joinDateUtcTicks: 0
behaviourAxes:
- axisName: "\u9898\u6D77\u6218\u672F"
@@ -229,6 +229,6 @@ MonoBehaviour:
skillDescriptionsText: "\u3010\u7ECA\u594F\xB7\u5411\u5F80\u3011\u6D88\u8017\u5168\u90E8\u7684\u6CD5\u529B\u503C\u65F6\uFF0C\u6D88\u8017\u81EA\u8EAB\u751F\u547D\u503C\u4E0A\u96503%\u7684\u751F\u547D\u503C\uFF08\u65E0\u6CD5\u964D\u81F3\u4E3A\u751F\u547D\u503C\u4E0A\u9650\u768420%\u53CA\u4EE5\u4E0B\uFF09\uFF0C\u5BF9\u654C\u4EBA\u9020\u6210\u4E00\u6B21\u91CD\u51FB\uFF08\u4F24\u5BB3\u503C\u7B49\u540C\u4E8E\u751F\u547D\u503C\u88AB\u6D88\u8017\u503C+\u89D2\u8272\u653B\u51FB\u529B10%\uFF09\u4F24\u5BB3\u3002"
thisSkill_levelLimit: 4
isSpecialSkill: 0
equippedSkillGroupIDs:
equippedEquipment: {fileID: 11400000, guid: 0bdbf424a6eaefc4aa14b6316dd7f82a, type: 2}
equippedEquipmentId: type0_20260325_00000005
equippedSkillGroupIDs: 95d8cc01
equippedEquipment: {fileID: 11400000, guid: 959aeb3b0e2a4b64a919837c789b4a4a, type: 2}
equippedEquipmentId: type0_20260325_00000012
@@ -39,4 +39,4 @@ MonoBehaviour:
- currencyType: 0
amount: 3
unlockRequirements: []
purchasedCount: 1455
purchasedCount: 1554
@@ -39,4 +39,4 @@ MonoBehaviour:
- currencyType: 0
amount: 4
unlockRequirements: []
purchasedCount: 2319
purchasedCount: 2418
@@ -39,4 +39,4 @@ MonoBehaviour:
- currencyType: 0
amount: 6
unlockRequirements: []
purchasedCount: 404
purchasedCount: 406
@@ -39,4 +39,4 @@ MonoBehaviour:
- currencyType: 0
amount: 7
unlockRequirements: []
purchasedCount: 305
purchasedCount: 404
@@ -39,4 +39,4 @@ MonoBehaviour:
- currencyType: 0
amount: 4
unlockRequirements: []
purchasedCount: 302
purchasedCount: 305
@@ -39,4 +39,4 @@ MonoBehaviour:
- currencyType: 0
amount: 1
unlockRequirements: []
purchasedCount: 1005
purchasedCount: 1006
+1 -1
View File
@@ -1900,7 +1900,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: "\u4E13\u5458\u8BC4\u4F30 \u7B2C\u4E00\u8F6E"
m_text: "\u4E13\u5458\u8BC4\u4F30 \u7B2C\u4E8C\u8F6E"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 47babadf44fc728438ae9a924c42227e, type: 2}
m_sharedMaterial: {fileID: 6312708493749940865, guid: 47babadf44fc728438ae9a924c42227e, type: 2}
File diff suppressed because it is too large Load Diff
+7683 -11
View File
File diff suppressed because it is too large Load Diff
+418 -21
View File
@@ -1598,9 +1598,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
slotIndex: 0
maxHP: 1
maxHP: 0
currentHP: 0
maxMana: 1
maxMana: 0
currentMana: 0
damageResistance: 0
scoreEfficiency: 1
@@ -3563,6 +3563,10 @@ MonoBehaviour:
golSO: {fileID: 11400000, guid: e3d476a4d3a88f840ba9668263c66b6c, type: 2}
galgamePrefab: {fileID: 7323059121263764531, guid: 00f0e57cae6a4694e99e3bc9d5d021af, type: 3}
where_to_put: {fileID: 167834970}
musicTimelineSource: {fileID: 845021791}
allowGlobalClickToAdvance: 1
keyboardAdvanceKey: 32
keyboardAdvanceKeyAlt: 13
--- !u!4 &167834972
Transform:
m_ObjectHideFlags: 0
@@ -11348,7 +11352,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 0%
m_Text: -/-
--- !u!222 &267454547
CanvasRenderer:
m_ObjectHideFlags: 0
@@ -12336,7 +12340,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 0%
m_Text: -/-
--- !u!222 &301683944
CanvasRenderer:
m_ObjectHideFlags: 0
@@ -16198,7 +16202,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 0/1
m_text: -/-
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 47babadf44fc728438ae9a924c42227e, type: 2}
m_sharedMaterial: {fileID: 6312708493749940865, guid: 47babadf44fc728438ae9a924c42227e, type: 2}
@@ -19098,7 +19102,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 0/1
m_text: -/-
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 47babadf44fc728438ae9a924c42227e, type: 2}
m_sharedMaterial: {fileID: 6312708493749940865, guid: 47babadf44fc728438ae9a924c42227e, type: 2}
@@ -22915,6 +22919,108 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 642051220}
m_CullTransparentMesh: 1
--- !u!1001 &643668620
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 1893636990}
m_Modifications:
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_SizeDelta.x
value: 150
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_SizeDelta.y
value: 35
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5437409420464746555, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_Name
value: rewardPrefab
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
--- !u!224 &643668621 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
m_PrefabInstance: {fileID: 643668620}
m_PrefabAsset: {fileID: 0}
--- !u!1 &646055728
GameObject:
m_ObjectHideFlags: 0
@@ -23323,6 +23429,108 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1001 &661080817
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 1893636990}
m_Modifications:
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_SizeDelta.x
value: 150
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_SizeDelta.y
value: 35
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5437409420464746555, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_Name
value: rewardPrefab (2)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
--- !u!224 &661080818 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
m_PrefabInstance: {fileID: 661080817}
m_PrefabAsset: {fileID: 0}
--- !u!1 &664127283
GameObject:
m_ObjectHideFlags: 0
@@ -29192,7 +29400,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 0%
m_Text: -/-
--- !u!222 &701852275
CanvasRenderer:
m_ObjectHideFlags: 0
@@ -35716,6 +35924,8 @@ MonoBehaviour:
introMvpEnterDuration: 0.42
introMvpEnterEase: 9
introTweenUseUnscaledTime: 1
rewardPrefab: {fileID: 5437409420464746555, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
rewardParent: {fileID: 1893636990}
--- !u!1 &882707961
GameObject:
m_ObjectHideFlags: 0
@@ -38827,7 +39037,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1017701769
RectTransform:
m_ObjectHideFlags: 0
@@ -39711,6 +39921,7 @@ RectTransform:
- {fileID: 1017701769}
- {fileID: 1271678590}
- {fileID: 1172773843}
- {fileID: 1893636990}
m_Father: {fileID: 518303505}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
@@ -43738,7 +43949,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 0/1
m_text: -/-
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 47babadf44fc728438ae9a924c42227e, type: 2}
m_sharedMaterial: {fileID: 6312708493749940865, guid: 47babadf44fc728438ae9a924c42227e, type: 2}
@@ -47470,7 +47681,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 0/1
m_text: -/-
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 47babadf44fc728438ae9a924c42227e, type: 2}
m_sharedMaterial: {fileID: 6312708493749940865, guid: 47babadf44fc728438ae9a924c42227e, type: 2}
@@ -48702,9 +48913,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
slotIndex: 3
maxHP: 1
maxHP: 0
currentHP: 0
maxMana: 1
maxMana: 0
currentMana: 0
damageResistance: 0
scoreEfficiency: 1
@@ -53174,9 +53385,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
slotIndex: 2
maxHP: 1
maxHP: 0
currentHP: 0
maxMana: 1
maxMana: 0
currentMana: 0
damageResistance: 0
scoreEfficiency: 1
@@ -55669,7 +55880,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 0%
m_Text: -/-
--- !u!222 &1594960623
CanvasRenderer:
m_ObjectHideFlags: 0
@@ -55895,9 +56106,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
slotIndex: 1
maxHP: 1
maxHP: 0
currentHP: 0
maxMana: 1
maxMana: 0
currentMana: 0
damageResistance: 0
scoreEfficiency: 1
@@ -56815,7 +57026,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 0%
m_Text: -/-
--- !u!222 &1648510628
CanvasRenderer:
m_ObjectHideFlags: 0
@@ -59000,6 +59211,108 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1001 &1739095549
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 1893636990}
m_Modifications:
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_SizeDelta.x
value: 150
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_SizeDelta.y
value: 35
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5437409420464746555, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
propertyPath: m_Name
value: rewardPrefab (1)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
--- !u!224 &1739095550 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 5127964937674371758, guid: 7e80d4de8ab2ff04a9bf1c54e5a064b1, type: 3}
m_PrefabInstance: {fileID: 1739095549}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1739624340
GameObject:
m_ObjectHideFlags: 0
@@ -62037,7 +62350,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 0/1
m_text: -/-
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 47babadf44fc728438ae9a924c42227e, type: 2}
m_sharedMaterial: {fileID: 6312708493749940865, guid: 47babadf44fc728438ae9a924c42227e, type: 2}
@@ -62684,9 +62997,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
slotIndex: 4
maxHP: 1
maxHP: 0
currentHP: 0
maxMana: 1
maxMana: 0
currentMana: 0
damageResistance: 0
scoreEfficiency: 1
@@ -62777,6 +63090,86 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1892592617}
m_CullTransparentMesh: 1
--- !u!1 &1893636989
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1893636990}
- component: {fileID: 1893636992}
- component: {fileID: 1893636991}
m_Layer: 0
m_Name: rewardParent
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1893636990
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1893636989}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 5.375322}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 643668621}
- {fileID: 1739095550}
- {fileID: 661080818}
m_Father: {fileID: 1040362012}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -8.74, y: -150}
m_SizeDelta: {x: 150, y: 0}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &1893636991
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1893636989}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 0
m_VerticalFit: 2
--- !u!114 &1893636992
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1893636989}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 0
m_Spacing: 10
m_ChildForceExpandWidth: 1
m_ChildForceExpandHeight: 1
m_ChildControlWidth: 0
m_ChildControlHeight: 0
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
--- !u!1 &1896638052
GameObject:
m_ObjectHideFlags: 0
@@ -74097,6 +74490,10 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1300093535825791683, guid: 00f0e57cae6a4694e99e3bc9d5d021af, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2908967551141921026, guid: 00f0e57cae6a4694e99e3bc9d5d021af, type: 3}
propertyPath: m_LocalPosition.x
value: 0
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ca757b56b551bc848847709590df8a06
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3a03a67ad5ea253479ad4b0932af1ca0
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d624baf52734e6342829047aa2c98f85
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e5d3ad2512302744fa1b4d76140d3dbd
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f58ba4d983a44a84b805d1dfd00ee406
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1 @@
assets/bansonic icon.png assetassets/bansonic icon.pngassets/font.otf assetassets/font.otf2packages/cupertino_icons/assets/CupertinoIcons.ttf asset2packages/cupertino_icons/assets/CupertinoIcons.ttf
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 358265b6e6f892e478f67ad8f80b80a5
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1 @@
[{"family":"MaterialIcons","fonts":[{"asset":"fonts/MaterialIcons-Regular.otf"}]},{"family":"Bansonic","fonts":[{"asset":"assets/font.otf"}]},{"family":"packages/cupertino_icons/CupertinoIcons","fonts":[{"asset":"packages/cupertino_icons/assets/CupertinoIcons.ttf"}]}]
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 015b1d621a35a784cbc38cfe4ec69195
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 129a7e22e56b40c4f93dbd30ba531cd9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1 @@
{"format-version":[1,0,0],"native-assets":{}}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b41c986bf11cb0c4584b0bfde211cc9b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a532cdda61aad4b438bd423ead3a63ac
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fd8485eb6d209404586d047ea5f75d49
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 71f1da0dd6589a04e99057c87fb49d33
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e71b8625b93658740b62ab5d71b721dd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 61cee88df66e79c469eb1acaf0d094f3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9df27906217f7b54f874fc96307d1931
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0338130400c677a43b94d8d5651b0233
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7de1d0810a2a5994da1ac8a8f76b7420
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f0621906f29999240a4df549a22eb71a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8476afc3ac9f48f4f8ccf38584939842
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: dccadc75ccaa95c4aa0284235d97ebce
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ec09c1a1438cf144d9c34f760127165a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: edf2cd4e4eccc254fa59e8096d6f2001
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 09502b497ac6ff14e9e9cfc9f5d5488d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 641e60becc3c7a8418ec97c5082a5836
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1f647a0b75135514e8598e8805e81b45
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 00c7416aa4a2e2c43888fa4920a9b8d0
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 82903184fabb94041970e4063f71c4cc
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bb9f012f380c23441a28cde3d792d130
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+10 -10
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
public class UISoundRouter : MonoBehaviour
{
private const bool VerboseLogs = false;
public static UISoundRouter Instance;
[SerializeField] private UISoundConfig soundConfig;
@@ -51,16 +52,16 @@ public class UISoundRouter : MonoBehaviour
if (soundConfig == null)
{
Debug.LogWarning("[UISoundRouter] SoundConfig is null! Cannot build lookup.");
if (VerboseLogs) Debug.LogWarning("[UISoundRouter] SoundConfig is null! Cannot build lookup.");
return;
}
Debug.Log($"[UISoundRouter] Building lookup for {soundConfig.name} with {soundConfig.soundTable.Count} entries.");
if (VerboseLogs) Debug.Log($"[UISoundRouter] Building lookup for {soundConfig.name} with {soundConfig.soundTable.Count} entries.");
foreach (var entry in soundConfig.soundTable)
{
lookup[entry.type] = entry;
Debug.Log($"[UISoundRouter] Registered sound for {entry.type}: Hover={entry.hoverClip?.name}, Click={entry.clickClip?.name}");
if (VerboseLogs) Debug.Log($"[UISoundRouter] Registered sound for {entry.type}: Hover={entry.hoverClip?.name}, Click={entry.clickClip?.name}");
}
}
@@ -80,12 +81,12 @@ public class UISoundRouter : MonoBehaviour
}
else
{
Debug.LogWarning($"[UISoundRouter] Hover clip is null for type {type}");
if (VerboseLogs) Debug.LogWarning($"[UISoundRouter] Hover clip is null for type {type}");
}
}
else
{
Debug.LogWarning($"[UISoundRouter] No entry found for type {type} in lookup.");
if (VerboseLogs) Debug.LogWarning($"[UISoundRouter] No entry found for type {type} in lookup.");
}
}
@@ -96,22 +97,21 @@ public class UISoundRouter : MonoBehaviour
lastClickTime = Time.unscaledTime;
Debug.Log($"[UISoundRouter] PlayClick called for type: {type}");
if (lookup != null && lookup.TryGetValue(type, out var entry))
{
if (entry.clickClip != null)
{
Debug.Log($"[UISoundRouter] Playing click clip: {entry.clickClip.name}");
if (VerboseLogs) Debug.Log($"[UISoundRouter] Playing click clip: {entry.clickClip.name}");
audioSource.PlayOneShot(entry.clickClip, 1.0f);
}
else
{
Debug.LogWarning($"[UISoundRouter] Click clip is null for type {type}");
if (VerboseLogs) Debug.LogWarning($"[UISoundRouter] Click clip is null for type {type}");
}
}
else
{
Debug.LogWarning($"[UISoundRouter] No entry found for type {type} in lookup.");
if (VerboseLogs) Debug.LogWarning($"[UISoundRouter] No entry found for type {type} in lookup.");
}
}
}
}
@@ -1,10 +1,10 @@
#if UNITY_EDITOR
#if UNITY_EDITOR
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Experimental.GraphView;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;
using System.Collections.Generic;
public class IngameGalgameGraphWindow : EditorWindow
{
@@ -46,15 +46,18 @@ public class IngameGalgameGraphWindow : EditorWindow
private void CreateToolbar()
{
var toolbar = new Toolbar();
var addBtn = new ToolbarButton(() => graphView?.CreateNodeAt(graphView.GetDefaultNodePosition())) { text = "+" };
var delBtn = new ToolbarButton(() => graphView?.DeleteSelected()) { text = "-" };
toolbar.Add(addBtn);
toolbar.Add(delBtn);
soField = new ObjectField("数据") { objectType = typeof(ingame_galgame_so), allowSceneObjects = false };
toolbar.Add(new ToolbarButton(() => graphView?.CreateNodeAt(graphView.GetDefaultNodePosition())) { text = "+" });
toolbar.Add(new ToolbarButton(() => graphView?.DeleteSelected()) { text = "-" });
soField = new ObjectField("数据")
{
objectType = typeof(ingame_galgame_so),
allowSceneObjects = false
};
soField.RegisterValueChangedCallback(evt => SetSo(evt.newValue as ingame_galgame_so));
toolbar.Add(soField);
var refreshBtn = new ToolbarButton(RefreshGraph) { text = "刷新" };
toolbar.Add(refreshBtn);
toolbar.Add(new ToolbarButton(RefreshGraph) { text = "刷新" });
rootVisualElement.Add(toolbar);
}
@@ -70,12 +73,16 @@ public class IngameGalgameGraphWindow : EditorWindow
private void RefreshGraph()
{
if (graphView == null) return;
if (graphView == null)
{
return;
}
graphView.Build(currentSo);
}
}
class IngameGalgameGraphView : GraphView
internal class IngameGalgameGraphView : GraphView
{
private ingame_galgame_so currentSo;
@@ -85,9 +92,11 @@ class IngameGalgameGraphView : GraphView
this.AddManipulator(new ContentDragger());
this.AddManipulator(new SelectionDragger());
this.AddManipulator(new RectangleSelector());
var grid = new GridBackground();
Insert(0, grid);
grid.StretchToParentSize();
SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale);
RegisterCallback<KeyDownEvent>(OnKeyDown);
}
@@ -96,18 +105,30 @@ class IngameGalgameGraphView : GraphView
{
ClearGraph();
currentSo = so;
if (so == null) return;
if (so == null)
{
return;
}
var serialized = new SerializedObject(so);
var dialogueList = serialized.FindProperty("dialogueList");
if (dialogueList == null || !dialogueList.isArray) return;
var speakerNames = BuildSpeakerNames(serialized);
if (dialogueList == null || !dialogueList.isArray)
{
return;
}
string[] speakerNames = BuildSpeakerNames(serialized);
DialogueTextNode prev = null;
for (int i = 0; i < dialogueList.arraySize; i++)
{
var elemProp = dialogueList.GetArrayElementAtIndex(i);
var positionTagProp = elemProp.FindPropertyRelative("positionTag");
var textListProp = elemProp.FindPropertyRelative("textList");
if (textListProp == null || !textListProp.isArray) continue;
if (textListProp == null || !textListProp.isArray)
{
continue;
}
for (int j = 0; j < textListProp.arraySize; j++)
{
var textProp = textListProp.GetArrayElementAtIndex(j);
@@ -116,8 +137,7 @@ class IngameGalgameGraphView : GraphView
AddElement(node);
if (prev != null)
{
var edge = prev.output.ConnectTo(node.input);
AddElement(edge);
AddElement(prev.output.ConnectTo(node.input));
}
prev = node;
}
@@ -136,10 +156,12 @@ class IngameGalgameGraphView : GraphView
private DialogueTextNode CreateTextNode(SerializedObject so, SerializedProperty positionTagProp, SerializedProperty textProp, string[] speakerNames, int elemIndex, int textIndex)
{
var node = new DialogueTextNode();
node.title = $"段落 {elemIndex + 1} / 文本 {textIndex + 1}";
node.elementIndex = elemIndex;
node.textIndex = textIndex;
var node = new DialogueTextNode
{
title = $"段落 {elemIndex + 1} / 文本 {textIndex + 1}",
elementIndex = elemIndex,
textIndex = textIndex
};
node.input = node.InstantiatePort(Orientation.Horizontal, Direction.Input, Port.Capacity.Multi, typeof(float));
node.input.portName = "输入";
node.output = node.InstantiatePort(Orientation.Horizontal, Direction.Output, Port.Capacity.Single, typeof(float));
@@ -149,18 +171,18 @@ class IngameGalgameGraphView : GraphView
if (positionTagProp != null)
{
var field = new PropertyField(positionTagProp, "位置标签");
var field = new PropertyField(positionTagProp, "显示模式");
field.Bind(so);
node.extensionContainer.Add(field);
}
AddTextField(node, so, textProp.FindPropertyRelative("content"), "内容");
AddIntPopup(node, so, textProp.FindPropertyRelative("senderIndex"), speakerNames);
AddField(node, so, textProp.FindPropertyRelative("content"), "文本内容");
AddSpeakerPopup(node, so, textProp.FindPropertyRelative("senderIndex"), speakerNames);
AddField(node, so, textProp.FindPropertyRelative("imagePos"), "图片位置");
AddField(node, so, textProp.FindPropertyRelative("flipX"), "水平翻转");
AddField(node, so, textProp.FindPropertyRelative("appearTime"), "出现时间");
AddField(node, so, textProp.FindPropertyRelative("duration"), "持续时间");
AddField(node, so, textProp.FindPropertyRelative("stepMethod"), "进方式");
AddField(node, so, textProp.FindPropertyRelative("stepMethod"), "进方式");
AddField(node, so, textProp.FindPropertyRelative("timeAction"), "时间动作");
AddField(node, so, textProp.FindPropertyRelative("slowMotionScale"), "慢动作倍率");
AddField(node, so, textProp.FindPropertyRelative("endAction"), "结束动作");
@@ -170,35 +192,36 @@ class IngameGalgameGraphView : GraphView
return node;
}
private void AddTextField(Node node, SerializedObject so, SerializedProperty prop, string label)
private static void AddField(Node node, SerializedObject so, SerializedProperty prop, string label)
{
if (prop == null) return;
var field = new PropertyField(prop, label);
field.Bind(so);
node.extensionContainer.Add(field);
}
private void AddField(Node node, SerializedObject so, SerializedProperty prop, string label)
{
if (prop == null) return;
var field = new PropertyField(prop, label);
field.Bind(so);
node.extensionContainer.Add(field);
}
private void AddIntPopup(Node node, SerializedObject so, SerializedProperty senderIndexProp, string[] speakerNames)
{
if (senderIndexProp == null) return;
if (speakerNames == null || speakerNames.Length == 0)
if (prop == null)
{
AddField(node, so, senderIndexProp, "发言者索引");
return;
}
var field = new PropertyField(prop, label);
field.Bind(so);
node.extensionContainer.Add(field);
}
private static void AddSpeakerPopup(Node node, SerializedObject so, SerializedProperty senderIndexProp, string[] speakerNames)
{
if (senderIndexProp == null)
{
return;
}
if (speakerNames == null || speakerNames.Length == 0)
{
AddField(node, so, senderIndexProp, "发言人");
return;
}
var imgui = new IMGUIContainer(() =>
{
so.Update();
int current = Mathf.Clamp(senderIndexProp.intValue + 1, 0, speakerNames.Length - 1);
int chosen = EditorGUILayout.Popup("发言", current, speakerNames);
int chosen = EditorGUILayout.Popup("发言", current, speakerNames);
senderIndexProp.intValue = Mathf.Max(-1, chosen - 1);
so.ApplyModifiedProperties();
});
@@ -208,17 +231,25 @@ class IngameGalgameGraphView : GraphView
private string[] BuildSpeakerNames(SerializedObject so)
{
var speakersDataSOProp = so.FindProperty("speakersDataSO");
if (speakersDataSOProp == null || speakersDataSOProp.objectReferenceValue == null) return null;
if (speakersDataSOProp == null || speakersDataSOProp.objectReferenceValue == null)
{
return null;
}
var speakersSO = new SerializedObject(speakersDataSOProp.objectReferenceValue);
var speakersList = speakersSO.FindProperty("speakers");
if (speakersList == null || !speakersList.isArray) return null;
int c = speakersList.arraySize;
var names = new string[c + 1];
names[0] = "(无)";
for (int i = 0; i < c; i++)
if (speakersList == null || !speakersList.isArray)
{
var e = speakersList.GetArrayElementAtIndex(i);
var nameProp = e.FindPropertyRelative("spkrName");
return null;
}
int count = speakersList.arraySize;
string[] names = new string[count + 1];
names[0] = "(无)";
for (int i = 0; i < count; i++)
{
var element = speakersList.GetArrayElementAtIndex(i);
var nameProp = element.FindPropertyRelative("spkrName");
names[i + 1] = nameProp != null ? nameProp.stringValue : $"Speaker {i}";
}
return names;
@@ -232,11 +263,19 @@ class IngameGalgameGraphView : GraphView
public void CreateNodeAt(Vector2 position)
{
if (currentSo == null) return;
if (currentSo == null)
{
return;
}
Undo.RecordObject(currentSo, "Create Dialogue Node");
var so = new SerializedObject(currentSo);
var dialogueList = so.FindProperty("dialogueList");
if (dialogueList == null) return;
if (dialogueList == null)
{
return;
}
int elemIndex = dialogueList.arraySize;
dialogueList.arraySize++;
var elemProp = dialogueList.GetArrayElementAtIndex(elemIndex);
@@ -252,6 +291,7 @@ class IngameGalgameGraphView : GraphView
ApplyTextDefaults(textProp);
}
}
so.ApplyModifiedProperties();
EditorUtility.SetDirty(currentSo);
Build(currentSo);
@@ -259,38 +299,69 @@ class IngameGalgameGraphView : GraphView
public void DeleteSelected()
{
if (currentSo == null) return;
var selectedNodes = new List<DialogueTextNode>();
foreach (var e in selection)
if (currentSo == null)
{
if (e is DialogueTextNode n) selectedNodes.Add(n);
return;
}
if (selectedNodes.Count == 0) return;
var selectedNodes = new List<DialogueTextNode>();
foreach (var element in selection)
{
if (element is DialogueTextNode node)
{
selectedNodes.Add(node);
}
}
if (selectedNodes.Count == 0)
{
return;
}
selectedNodes.Sort((a, b) =>
{
int c = b.elementIndex.CompareTo(a.elementIndex);
return c != 0 ? c : b.textIndex.CompareTo(a.textIndex);
int compare = b.elementIndex.CompareTo(a.elementIndex);
return compare != 0 ? compare : b.textIndex.CompareTo(a.textIndex);
});
Undo.RecordObject(currentSo, "Delete Dialogue Node");
var so = new SerializedObject(currentSo);
var dialogueList = so.FindProperty("dialogueList");
if (dialogueList == null) return;
if (dialogueList == null)
{
return;
}
foreach (var node in selectedNodes)
{
if (node.elementIndex < 0 || node.elementIndex >= dialogueList.arraySize) continue;
if (node.elementIndex < 0 || node.elementIndex >= dialogueList.arraySize)
{
continue;
}
var elemProp = dialogueList.GetArrayElementAtIndex(node.elementIndex);
if (elemProp == null) continue;
if (elemProp == null)
{
continue;
}
var textListProp = elemProp.FindPropertyRelative("textList");
if (textListProp == null) continue;
if (textListProp == null)
{
continue;
}
if (node.textIndex >= 0 && node.textIndex < textListProp.arraySize)
{
textListProp.DeleteArrayElementAtIndex(node.textIndex);
}
if (textListProp.arraySize <= 0)
{
dialogueList.DeleteArrayElementAtIndex(node.elementIndex);
}
}
so.ApplyModifiedProperties();
EditorUtility.SetDirty(currentSo);
Build(currentSo);
@@ -299,12 +370,18 @@ class IngameGalgameGraphView : GraphView
public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
{
evt.menu.AppendAction("新建节点", _ => CreateNodeAt(evt.localMousePosition));
bool hasSelection = false;
foreach (var e in selection)
foreach (var element in selection)
{
if (e is DialogueTextNode) { hasSelection = true; break; }
if (element is DialogueTextNode)
{
hasSelection = true;
break;
}
}
evt.menu.AppendAction("删除所选", _ => DeleteSelected(), hasSelection ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled);
evt.menu.AppendAction("删除选中", _ => DeleteSelected(), hasSelection ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled);
}
private void OnKeyDown(KeyDownEvent evt)
@@ -328,65 +405,108 @@ class IngameGalgameGraphView : GraphView
private string SerializeSelection()
{
if (currentSo == null) return string.Empty;
if (currentSo == null)
{
return string.Empty;
}
var payload = new DialogueCopyPayload();
var so = new SerializedObject(currentSo);
var dialogueList = so.FindProperty("dialogueList");
foreach (var e in selection)
foreach (var element in selection)
{
if (e is not DialogueTextNode node) continue;
if (dialogueList == null) continue;
if (node.elementIndex < 0 || node.elementIndex >= dialogueList.arraySize) continue;
if (element is not DialogueTextNode node || dialogueList == null)
{
continue;
}
if (node.elementIndex < 0 || node.elementIndex >= dialogueList.arraySize)
{
continue;
}
var elemProp = dialogueList.GetArrayElementAtIndex(node.elementIndex);
if (elemProp == null) continue;
var positionTagProp = elemProp.FindPropertyRelative("positionTag");
var textListProp = elemProp.FindPropertyRelative("textList");
if (textListProp == null) continue;
if (node.textIndex < 0 || node.textIndex >= textListProp.arraySize) continue;
var positionTagProp = elemProp?.FindPropertyRelative("positionTag");
var textListProp = elemProp?.FindPropertyRelative("textList");
if (textListProp == null || node.textIndex < 0 || node.textIndex >= textListProp.arraySize)
{
continue;
}
var textProp = textListProp.GetArrayElementAtIndex(node.textIndex);
if (textProp == null) continue;
var data = new DialogueTextCopyData();
data.positionTag = positionTagProp != null ? positionTagProp.enumValueIndex : 0;
data.content = textProp.FindPropertyRelative("content")?.stringValue;
data.textNumber = textProp.FindPropertyRelative("textNumber")?.intValue ?? 0;
data.senderIndex = textProp.FindPropertyRelative("senderIndex")?.intValue ?? -1;
data.imagePos = textProp.FindPropertyRelative("imagePos")?.enumValueIndex ?? 0;
data.flipX = textProp.FindPropertyRelative("flipX")?.boolValue ?? false;
data.appearTime = textProp.FindPropertyRelative("appearTime")?.floatValue ?? 0f;
data.duration = textProp.FindPropertyRelative("duration")?.floatValue ?? 0f;
data.stepMethod = textProp.FindPropertyRelative("stepMethod")?.enumValueIndex ?? 0;
data.timeAction = textProp.FindPropertyRelative("timeAction")?.enumValueIndex ?? 0;
data.slowMotionScale = textProp.FindPropertyRelative("slowMotionScale")?.floatValue ?? 0f;
data.endAction = textProp.FindPropertyRelative("endAction")?.enumValueIndex ?? 0;
payload.items.Add(data);
if (textProp == null)
{
continue;
}
payload.items.Add(new DialogueTextCopyData
{
positionTag = positionTagProp != null ? positionTagProp.enumValueIndex : 0,
content = textProp.FindPropertyRelative("content")?.stringValue,
textNumber = textProp.FindPropertyRelative("textNumber")?.intValue ?? 0,
senderIndex = textProp.FindPropertyRelative("senderIndex")?.intValue ?? -1,
imagePos = textProp.FindPropertyRelative("imagePos")?.enumValueIndex ?? 0,
flipX = textProp.FindPropertyRelative("flipX")?.boolValue ?? false,
appearTime = textProp.FindPropertyRelative("appearTime")?.floatValue ?? 0f,
duration = textProp.FindPropertyRelative("duration")?.floatValue ?? 0f,
stepMethod = textProp.FindPropertyRelative("stepMethod")?.enumValueIndex ?? 0,
timeAction = textProp.FindPropertyRelative("timeAction")?.enumValueIndex ?? 0,
slowMotionScale = textProp.FindPropertyRelative("slowMotionScale")?.floatValue ?? 0f,
endAction = textProp.FindPropertyRelative("endAction")?.enumValueIndex ?? 0
});
}
return payload.items.Count == 0 ? string.Empty : JsonUtility.ToJson(payload);
}
private bool CanPasteDataInternal(string serializedData)
private static bool CanPasteDataInternal(string serializedData)
{
if (string.IsNullOrEmpty(serializedData)) return false;
if (string.IsNullOrEmpty(serializedData))
{
return false;
}
var payload = JsonUtility.FromJson<DialogueCopyPayload>(serializedData);
return payload != null && payload.items != null && payload.items.Count > 0;
}
private void PasteFromClipboard()
{
if (currentSo == null) return;
if (currentSo == null)
{
return;
}
var serializedData = EditorGUIUtility.systemCopyBuffer;
if (!CanPasteDataInternal(serializedData)) return;
if (!CanPasteDataInternal(serializedData))
{
return;
}
var payload = JsonUtility.FromJson<DialogueCopyPayload>(serializedData);
if (payload == null || payload.items == null || payload.items.Count == 0) return;
if (payload == null || payload.items == null || payload.items.Count == 0)
{
return;
}
Undo.RecordObject(currentSo, "Paste Dialogue Node");
var so = new SerializedObject(currentSo);
var dialogueList = so.FindProperty("dialogueList");
if (dialogueList == null) return;
if (dialogueList == null)
{
return;
}
foreach (var item in payload.items)
{
int elemIndex = dialogueList.arraySize;
dialogueList.arraySize++;
var elemProp = dialogueList.GetArrayElementAtIndex(elemIndex);
if (elemProp == null) continue;
if (elemProp == null)
{
continue;
}
var positionTagProp = elemProp.FindPropertyRelative("positionTag");
if (positionTagProp != null) positionTagProp.enumValueIndex = item.positionTag;
var textListProp = elemProp.FindPropertyRelative("textList");
@@ -397,14 +517,19 @@ class IngameGalgameGraphView : GraphView
ApplyTextData(textProp, item);
}
}
so.ApplyModifiedProperties();
EditorUtility.SetDirty(currentSo);
Build(currentSo);
}
private void ApplyTextDefaults(SerializedProperty textProp)
private static void ApplyTextDefaults(SerializedProperty textProp)
{
if (textProp == null) return;
if (textProp == null)
{
return;
}
textProp.FindPropertyRelative("content").stringValue = string.Empty;
textProp.FindPropertyRelative("textNumber").intValue = 1;
textProp.FindPropertyRelative("senderIndex").intValue = -1;
@@ -412,16 +537,20 @@ class IngameGalgameGraphView : GraphView
var flipXProp = textProp.FindPropertyRelative("flipX");
if (flipXProp != null) flipXProp.boolValue = false;
textProp.FindPropertyRelative("appearTime").floatValue = 0f;
textProp.FindPropertyRelative("duration").floatValue = 0f;
textProp.FindPropertyRelative("duration").floatValue = 1f;
textProp.FindPropertyRelative("stepMethod").enumValueIndex = 0;
textProp.FindPropertyRelative("timeAction").enumValueIndex = 0;
textProp.FindPropertyRelative("slowMotionScale").floatValue = 0f;
textProp.FindPropertyRelative("slowMotionScale").floatValue = 0.5f;
textProp.FindPropertyRelative("endAction").enumValueIndex = 0;
}
private void ApplyTextData(SerializedProperty textProp, DialogueTextCopyData data)
private static void ApplyTextData(SerializedProperty textProp, DialogueTextCopyData data)
{
if (textProp == null || data == null) return;
if (textProp == null || data == null)
{
return;
}
textProp.FindPropertyRelative("content").stringValue = data.content ?? string.Empty;
textProp.FindPropertyRelative("textNumber").intValue = data.textNumber;
textProp.FindPropertyRelative("senderIndex").intValue = data.senderIndex;
@@ -460,7 +589,7 @@ class IngameGalgameGraphView : GraphView
}
}
class DialogueTextNode : Node
internal class DialogueTextNode : Node
{
public Port input;
public Port output;
@@ -1,9 +1,10 @@
#if UNITY_EDITOR
#if UNITY_EDITOR
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using System.Collections.Generic;
using System.Reflection;
[CustomEditor(typeof(ScriptableObject), true)]
public class ingame_galgame_so_Editor : Editor
@@ -12,6 +13,7 @@ public class ingame_galgame_so_Editor : Editor
private SerializedProperty timelineStandardProp;
private SerializedProperty dialogueTypeProp;
private SerializedProperty speakersDataSOProp;
private SerializedProperty jsonDefinitionAssetProp;
private SerializedProperty dialogueListProp;
private ReorderableList dialogueListRl;
@@ -20,18 +22,18 @@ public class ingame_galgame_so_Editor : Editor
private readonly GUIContent labelDialogueType = new GUIContent("对话类型");
private readonly GUIContent labelTriggerMethod = new GUIContent("触发方式");
private readonly GUIContent labelTimelineStandard = new GUIContent("时间线基准");
private readonly GUIContent labelTimelineStandard = new GUIContent("时间基准");
private readonly GUIContent labelSpeakers = new GUIContent("角色数据");
private readonly GUIContent labelPositionTag = new GUIContent("位置标签");
private readonly GUIContent labelContent = new GUIContent("内容");
private readonly GUIContent labelTextNumber = new GUIContent("文本序号");
private readonly GUIContent labelSender = new GUIContent("发言者");
private readonly GUIContent labelSenderIndex = new GUIContent("发言者索引");
private readonly GUIContent labelJsonDefinition = new GUIContent("JSON 覆盖源");
private readonly GUIContent labelPositionTag = new GUIContent("显示模式");
private readonly GUIContent labelContent = new GUIContent("文本内容");
private readonly GUIContent labelTextNumber = new GUIContent("文本编号");
private readonly GUIContent labelSenderIndex = new GUIContent("发言");
private readonly GUIContent labelImagePos = new GUIContent("图片位置");
private readonly GUIContent labelFlipX = new GUIContent("水平翻转");
private readonly GUIContent labelAppearTime = new GUIContent("出现时间");
private readonly GUIContent labelDuration = new GUIContent("持续时间");
private readonly GUIContent labelStepMethod = new GUIContent("进方式");
private readonly GUIContent labelStepMethod = new GUIContent("进方式");
private readonly GUIContent labelTimeAction = new GUIContent("时间动作");
private readonly GUIContent labelSlowMotionScale = new GUIContent("慢动作倍率");
private readonly GUIContent labelEndAction = new GUIContent("结束动作");
@@ -44,8 +46,10 @@ public class ingame_galgame_so_Editor : Editor
timelineStandardProp = serializedObject.FindProperty("timelineStandard");
dialogueTypeProp = serializedObject.FindProperty("dialogueType");
speakersDataSOProp = serializedObject.FindProperty("speakersDataSO");
jsonDefinitionAssetProp = serializedObject.FindProperty("jsonDefinitionAsset");
dialogueListProp = serializedObject.FindProperty("dialogueList");
}
dialogueListRl = null;
textListRlMap.Clear();
}
@@ -76,15 +80,101 @@ public class ingame_galgame_so_Editor : Editor
if (triggerMethodProp != null) EditorGUILayout.PropertyField(triggerMethodProp, labelTriggerMethod);
if (timelineStandardProp != null) EditorGUILayout.PropertyField(timelineStandardProp, labelTimelineStandard);
if (speakersDataSOProp != null) EditorGUILayout.PropertyField(speakersDataSOProp, labelSpeakers);
if (jsonDefinitionAssetProp != null) EditorGUILayout.PropertyField(jsonDefinitionAssetProp, labelJsonDefinition);
var so = target as ingame_galgame_so;
if (so != null)
{
EditorGUILayout.HelpBox(
so.HasJsonOverride
? "当前已配置 JSON 覆盖源,运行时将优先使用 JSON 内容。"
: "当前未配置 JSON 覆盖源,运行时将使用 Inspector 中的配置。",
MessageType.Info);
}
if (GUILayout.Button("打开蓝图视图"))
{
var t = typeof(ingame_galgame_so_Editor).Assembly.GetType("IngameGalgameGraphWindow");
var m = t != null ? t.GetMethod("Open", BindingFlags.Public | BindingFlags.Static) : null;
if (m != null) m.Invoke(null, new object[] { target as ingame_galgame_so });
var type = typeof(ingame_galgame_so_Editor).Assembly.GetType("IngameGalgameGraphWindow");
var method = type != null ? type.GetMethod("Open", BindingFlags.Public | BindingFlags.Static) : null;
if (method != null)
{
method.Invoke(null, new object[] { target as ingame_galgame_so });
}
}
if (GUILayout.Button("导出当前 SO 为 JSON"))
{
ExportCurrentSoAsJson();
}
using (new EditorGUI.DisabledScope(so == null || !so.HasJsonOverride))
{
if (GUILayout.Button("从 JSON 一键填入当前 SO"))
{
ImportJsonIntoCurrentSo();
}
}
EditorGUILayout.EndVertical();
}
private void ExportCurrentSoAsJson()
{
if (target is not ingame_galgame_so so)
{
return;
}
string defaultName = $"{so.name}.json";
string path = EditorUtility.SaveFilePanelInProject(
"导出 Galgame JSON",
defaultName,
"json",
"选择 JSON 导出位置");
if (string.IsNullOrWhiteSpace(path))
{
return;
}
File.WriteAllText(path, so.ExportCurrentDefinitionToJson(true), System.Text.Encoding.UTF8);
AssetDatabase.Refresh();
TextAsset exportedJson = AssetDatabase.LoadAssetAtPath<TextAsset>(path);
if (jsonDefinitionAssetProp != null && exportedJson != null)
{
serializedObject.Update();
jsonDefinitionAssetProp.objectReferenceValue = exportedJson;
serializedObject.ApplyModifiedProperties();
}
EditorGUIUtility.PingObject(exportedJson);
}
private void ImportJsonIntoCurrentSo()
{
if (target is not ingame_galgame_so so)
{
return;
}
serializedObject.ApplyModifiedProperties();
if (!so.TryApplyJsonOverrideToInspector(out string errorMessage))
{
EditorUtility.DisplayDialog("导入 JSON 失败", string.IsNullOrWhiteSpace(errorMessage) ? "无法从 JSON 回填到当前 SO。" : errorMessage, "确定");
return;
}
EditorUtility.SetDirty(so);
serializedObject.Update();
dialogueListRl = null;
textListRlMap.Clear();
Repaint();
AssetDatabase.SaveAssets();
EditorUtility.DisplayDialog("导入成功", "已将当前 JSON 内容回填到 SO Inspector 数据中。", "确定");
}
private void DrawDialogueSection()
{
if (dialogueListProp == null)
@@ -100,112 +190,133 @@ public class ingame_galgame_so_Editor : Editor
private void EnsureDialogueList()
{
if (dialogueListRl != null && dialogueListRl.serializedProperty == dialogueListProp) return;
if (dialogueListRl != null && dialogueListRl.serializedProperty == dialogueListProp)
{
return;
}
dialogueListRl = new ReorderableList(serializedObject, dialogueListProp, true, true, true, true);
dialogueListRl.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "对话列表");
dialogueListRl.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "对话段落列表");
dialogueListRl.elementHeightCallback = index =>
{
var elemProp = dialogueListProp.GetArrayElementAtIndex(index);
float line = EditorGUIUtility.singleLineHeight;
float space = EditorGUIUtility.standardVerticalSpacing;
float h = line + space;
float height = line + space;
if (elemProp != null && elemProp.isExpanded)
{
var positionTagProp = elemProp.FindPropertyRelative("positionTag");
if (positionTagProp != null) h += EditorGUI.GetPropertyHeight(positionTagProp, true) + space;
if (positionTagProp != null) height += EditorGUI.GetPropertyHeight(positionTagProp, true) + space;
var textListProp = elemProp.FindPropertyRelative("textList");
if (textListProp != null)
{
var rl = GetTextList(textListProp);
if (rl != null) h += rl.GetHeight() + space;
if (rl != null) height += rl.GetHeight() + space;
}
}
return h;
return height;
};
dialogueListRl.drawElementCallback = (rect, index, isActive, isFocused) =>
{
var elemProp = dialogueListProp.GetArrayElementAtIndex(index);
if (elemProp == null) return;
if (elemProp == null)
{
return;
}
float line = EditorGUIUtility.singleLineHeight;
float space = EditorGUIUtility.standardVerticalSpacing;
Rect r = rect;
r.height = line;
elemProp.isExpanded = EditorGUI.Foldout(r, elemProp.isExpanded, $"段落 {index + 1}", true);
if (!elemProp.isExpanded) return;
r.y += line + space;
Rect rowRect = rect;
rowRect.height = line;
elemProp.isExpanded = EditorGUI.Foldout(rowRect, elemProp.isExpanded, $"段落 {index + 1}", true);
if (!elemProp.isExpanded)
{
return;
}
rowRect.y += line + space;
EditorGUI.indentLevel++;
var positionTagProp = elemProp.FindPropertyRelative("positionTag");
if (positionTagProp != null)
{
EditorGUI.PropertyField(r, positionTagProp, labelPositionTag);
r.y += line + space;
EditorGUI.PropertyField(rowRect, positionTagProp, labelPositionTag);
rowRect.y += line + space;
}
var textListProp = elemProp.FindPropertyRelative("textList");
if (textListProp != null)
{
var rl = GetTextList(textListProp);
if (rl != null)
{
r.height = rl.GetHeight();
rl.DoList(r);
rowRect.height = rl.GetHeight();
rl.DoList(rowRect);
}
}
EditorGUI.indentLevel--;
};
}
private ReorderableList GetTextList(SerializedProperty textListProp)
{
if (textListProp == null) return null;
if (textListProp == null)
{
return null;
}
string key = textListProp.propertyPath;
if (!textListRlMap.TryGetValue(key, out var rl) || rl.serializedProperty != textListProp)
{
rl = new ReorderableList(serializedObject, textListProp, true, true, true, true);
rl.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "文本列表");
rl.elementHeightCallback = index =>
{
var textProp = textListProp.GetArrayElementAtIndex(index);
return GetTextElementHeight(textProp);
};
rl.drawElementCallback = (rect, index, isActive, isFocused) =>
{
var textProp = textListProp.GetArrayElementAtIndex(index);
DrawTextElement(rect, textProp);
};
rl.elementHeightCallback = index => GetTextElementHeight(textListProp.GetArrayElementAtIndex(index));
rl.drawElementCallback = (rect, index, isActive, isFocused) => DrawTextElement(rect, textListProp.GetArrayElementAtIndex(index));
textListRlMap[key] = rl;
}
return rl;
}
private float GetTextElementHeight(SerializedProperty textProp)
{
if (textProp == null) return EditorGUIUtility.singleLineHeight;
if (textProp == null)
{
return EditorGUIUtility.singleLineHeight;
}
float space = EditorGUIUtility.standardVerticalSpacing;
float h = 0f;
float padding = 4f;
float height = 0f;
SerializedProperty prop;
prop = textProp.FindPropertyRelative("content"); if (prop != null) h += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("textNumber"); if (prop != null) h += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("senderIndex"); if (prop != null) h += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("imagePos"); if (prop != null) h += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("flipX"); if (prop != null) h += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("appearTime"); if (prop != null) h += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("duration"); if (prop != null) h += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("stepMethod"); if (prop != null) h += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("timeAction"); if (prop != null) h += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("slowMotionScale"); if (prop != null) h += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("endAction"); if (prop != null) h += EditorGUI.GetPropertyHeight(prop, true) + space;
return h + padding * 2f;
prop = textProp.FindPropertyRelative("content"); if (prop != null) height += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("textNumber"); if (prop != null) height += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("senderIndex"); if (prop != null) height += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("imagePos"); if (prop != null) height += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("flipX"); if (prop != null) height += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("appearTime"); if (prop != null) height += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("duration"); if (prop != null) height += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("stepMethod"); if (prop != null) height += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("timeAction"); if (prop != null) height += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("slowMotionScale"); if (prop != null) height += EditorGUI.GetPropertyHeight(prop, true) + space;
prop = textProp.FindPropertyRelative("endAction"); if (prop != null) height += EditorGUI.GetPropertyHeight(prop, true) + space;
return height + padding * 2f;
}
private void DrawTextElement(Rect rect, SerializedProperty textProp)
{
if (textProp == null) return;
if (textProp == null)
{
return;
}
float line = EditorGUIUtility.singleLineHeight;
float space = EditorGUIUtility.standardVerticalSpacing;
float padding = 4f;
Rect r = rect;
r.y += padding;
Rect rowRect = rect;
rowRect.y += padding;
var contentProp = textProp.FindPropertyRelative("content");
var textNumberProp = textProp.FindPropertyRelative("textNumber");
@@ -221,69 +332,77 @@ public class ingame_galgame_so_Editor : Editor
if (contentProp != null)
{
r.height = EditorGUI.GetPropertyHeight(contentProp, true);
EditorGUI.PropertyField(r, contentProp, labelContent, true);
r.y += r.height + space;
rowRect.height = EditorGUI.GetPropertyHeight(contentProp, true);
EditorGUI.PropertyField(rowRect, contentProp, labelContent, true);
rowRect.y += rowRect.height + space;
}
r.height = line;
if (textNumberProp != null) EditorGUI.PropertyField(r, textNumberProp, labelTextNumber);
r.y += line + space;
rowRect.height = line;
if (textNumberProp != null) EditorGUI.PropertyField(rowRect, textNumberProp, labelTextNumber);
rowRect.y += line + space;
if (senderIndexProp != null)
{
if (speakerNames != null && speakerNames.Length > 0)
{
int current = Mathf.Clamp(senderIndexProp.intValue + 1, 0, speakerNames.Length - 1);
int chosen = EditorGUI.Popup(r, "发言", current, speakerNames);
int chosen = EditorGUI.Popup(rowRect, "发言", current, speakerNames);
senderIndexProp.intValue = Mathf.Max(-1, chosen - 1);
}
else
{
EditorGUI.PropertyField(r, senderIndexProp, labelSenderIndex);
EditorGUI.PropertyField(rowRect, senderIndexProp, labelSenderIndex);
}
r.y += line + space;
rowRect.y += line + space;
}
if (imagePosProp != null) EditorGUI.PropertyField(r, imagePosProp, labelImagePos);
r.y += line + space;
if (imagePosProp != null) EditorGUI.PropertyField(rowRect, imagePosProp, labelImagePos);
rowRect.y += line + space;
if (flipXProp != null) EditorGUI.PropertyField(r, flipXProp, labelFlipX);
r.y += line + space;
if (flipXProp != null) EditorGUI.PropertyField(rowRect, flipXProp, labelFlipX);
rowRect.y += line + space;
if (appearTimeProp != null) EditorGUI.PropertyField(r, appearTimeProp, labelAppearTime);
r.y += line + space;
if (appearTimeProp != null) EditorGUI.PropertyField(rowRect, appearTimeProp, labelAppearTime);
rowRect.y += line + space;
if (durationProp != null) EditorGUI.PropertyField(r, durationProp, labelDuration);
r.y += line + space;
if (durationProp != null) EditorGUI.PropertyField(rowRect, durationProp, labelDuration);
rowRect.y += line + space;
if (stepMethodProp != null) EditorGUI.PropertyField(r, stepMethodProp, labelStepMethod);
r.y += line + space;
if (stepMethodProp != null) EditorGUI.PropertyField(rowRect, stepMethodProp, labelStepMethod);
rowRect.y += line + space;
if (timeActionProp != null) EditorGUI.PropertyField(r, timeActionProp, labelTimeAction);
r.y += line + space;
if (timeActionProp != null) EditorGUI.PropertyField(rowRect, timeActionProp, labelTimeAction);
rowRect.y += line + space;
if (slowMotionProp != null) EditorGUI.PropertyField(r, slowMotionProp, labelSlowMotionScale);
r.y += line + space;
if (slowMotionProp != null) EditorGUI.PropertyField(rowRect, slowMotionProp, labelSlowMotionScale);
rowRect.y += line + space;
if (endActionProp != null) EditorGUI.PropertyField(r, endActionProp, labelEndAction);
if (endActionProp != null) EditorGUI.PropertyField(rowRect, endActionProp, labelEndAction);
}
private void BuildSpeakerNames()
{
speakerNames = null;
Object speakersObj = speakersDataSOProp != null ? speakersDataSOProp.objectReferenceValue : null;
if (speakersObj == null) return;
if (speakersObj == null)
{
return;
}
var speakersSO = new SerializedObject(speakersObj);
var speakersList = speakersSO.FindProperty("speakers");
if (speakersList == null || !speakersList.isArray) return;
int c = speakersList.arraySize;
speakerNames = new string[c + 1];
speakerNames[0] = "(无)";
for (int i = 0; i < c; i++)
if (speakersList == null || !speakersList.isArray)
{
var e = speakersList.GetArrayElementAtIndex(i);
var nameProp = e.FindPropertyRelative("spkrName");
return;
}
int count = speakersList.arraySize;
speakerNames = new string[count + 1];
speakerNames[0] = "(无)";
for (int i = 0; i < count; i++)
{
var element = speakersList.GetArrayElementAtIndex(i);
var nameProp = element.FindPropertyRelative("spkrName");
speakerNames[i + 1] = nameProp != null ? nameProp.stringValue : $"Speaker {i}";
}
}
@@ -294,6 +413,7 @@ public class ingame_galgame_so_Editor : Editor
if (timelineStandardProp == null) timelineStandardProp = serializedObject.FindProperty("timelineStandard");
if (dialogueTypeProp == null) dialogueTypeProp = serializedObject.FindProperty("dialogueType");
if (speakersDataSOProp == null) speakersDataSOProp = serializedObject.FindProperty("speakersDataSO");
if (jsonDefinitionAssetProp == null) jsonDefinitionAssetProp = serializedObject.FindProperty("jsonDefinitionAsset");
if (dialogueListProp == null) dialogueListProp = serializedObject.FindProperty("dialogueList");
}
}
+223 -22
View File
@@ -1,15 +1,14 @@
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class galPrefab : MonoBehaviour
{
[Header("NowUsing")]
[SerializeField] private int nowUsing = 0; // 0: none, 1: RoleHost, 2: RoleHint, 3: Narration, 4: HintOrLyrics
[Header("publics")]
public Color defaultTextColor;
[Header("默认文本颜色")]
public Color defaultTextColor = Color.white;
[Header("mode1: RoleHost")]
[Header("模式1: 角色正式对话")]
public Image roleHostBGbar;
public Image L_roleHostImage;
public Image R_roleHosetImage;
@@ -17,30 +16,167 @@ public class galPrefab : MonoBehaviour
public TextMeshProUGUI roleHostMessage;
public Button host_nextButton;
[Header("mode2: RoleHint")]
[Header("模式2: 角色提示对话")]
public Image roleHintBGbar;
public Image roleHintImage;
public TextMeshProUGUI roleHintName;
public TextMeshProUGUI roleHintMessage;
public Button hint_nextButton;
[Header("mode3: Narration")]
[Header("模式3: 旁白")]
public Image narrationBGbar;
public TextMeshProUGUI narrationMessage;
[Header("mode4: HintOrLyrics")]
[Header("模式4: 提示或歌词")]
public Image hintOrLyricsBGbar;
public TextMeshProUGUI hintOrLyricsMessage;
[Header("fathers of 4modes")]
[Header("四种模式容器")]
public GameObject roleHostFather;
public GameObject roleHintFather;
public GameObject narrationFather;
public GameObject hintOrLyricsFather;
private Action advanceCallback;
private void Awake()
{
BindButtons();
HideAllModes();
}
private void Start()
{
// Try to find cameras from Camera.allCameras first
TryAssignCanvasCamera();
}
public void Initialize(Action onAdvance)
{
advanceCallback = onAdvance;
BindButtons();
HideAllModes();
}
public void Present(
ingame_galgame_so.DialogueElement.PositionTag positionTag,
ingame_galgame_so.DialogueText dialogue,
Speaker speaker)
{
if (dialogue == null)
{
HideAllModes();
return;
}
HideAllModes();
switch (positionTag)
{
case ingame_galgame_so.DialogueElement.PositionTag.RoleHost:
PresentRoleHost(dialogue, speaker);
break;
case ingame_galgame_so.DialogueElement.PositionTag.RoleHint:
PresentRoleHint(dialogue, speaker);
break;
case ingame_galgame_so.DialogueElement.PositionTag.Narration:
PresentNarration(dialogue);
break;
case ingame_galgame_so.DialogueElement.PositionTag.HintOrLyrics:
PresentHintOrLyrics(dialogue);
break;
default:
PresentNarration(dialogue);
break;
}
}
public void HideAllModes()
{
SetActiveSafe(roleHostFather, false);
SetActiveSafe(roleHintFather, false);
SetActiveSafe(narrationFather, false);
SetActiveSafe(hintOrLyricsFather, false);
}
public void SetAdvanceEnabled(bool enabled)
{
SetButtonEnabled(host_nextButton, enabled);
SetButtonEnabled(hint_nextButton, enabled);
}
private void PresentRoleHost(ingame_galgame_so.DialogueText dialogue, Speaker speaker)
{
SetActiveSafe(roleHostFather, true);
Color accent = speaker != null ? speaker.spkr_themeColor : defaultTextColor;
string speakerName = speaker != null ? speaker.spkrName : string.Empty;
Sprite portrait = speaker != null ? speaker.spkrHD_Sprite : null;
ApplyImage(roleHostBGbar, roleHostBGbar != null ? roleHostBGbar.sprite : null, accent, true);
ApplyText(roleHostName, speakerName, accent);
ApplyText(roleHostMessage, dialogue.content, defaultTextColor);
bool leftActive = dialogue.imagePos == ingame_galgame_so.DialogueText.ImagePosition.Left;
bool rightActive = !leftActive;
ApplyPortrait(L_roleHostImage, leftActive ? portrait : null, leftActive, dialogue.flipX);
ApplyPortrait(R_roleHosetImage, rightActive ? portrait : null, rightActive, dialogue.flipX);
}
private void PresentRoleHint(ingame_galgame_so.DialogueText dialogue, Speaker speaker)
{
SetActiveSafe(roleHintFather, true);
Color accent = speaker != null ? speaker.spkr_themeColor : defaultTextColor;
string speakerName = speaker != null ? speaker.spkrName : string.Empty;
Sprite portrait = null;
if (speaker != null)
{
portrait = speaker.spkrProfile_Sprite != null ? speaker.spkrProfile_Sprite : speaker.spkrHD_Sprite;
}
ApplyImage(roleHintBGbar, roleHintBGbar != null ? roleHintBGbar.sprite : null, accent, true);
ApplyPortrait(roleHintImage, portrait, portrait != null, dialogue.flipX);
ApplyText(roleHintName, speakerName, accent);
ApplyText(roleHintMessage, dialogue.content, defaultTextColor);
}
private void PresentNarration(ingame_galgame_so.DialogueText dialogue)
{
SetActiveSafe(narrationFather, true);
ApplyText(narrationMessage, dialogue.content, defaultTextColor);
}
private void PresentHintOrLyrics(ingame_galgame_so.DialogueText dialogue)
{
SetActiveSafe(hintOrLyricsFather, true);
ApplyText(hintOrLyricsMessage, dialogue.content, defaultTextColor);
}
private void BindButtons()
{
BindButton(host_nextButton);
BindButton(hint_nextButton);
}
private void BindButton(Button button)
{
if (button == null)
{
return;
}
button.onClick.RemoveListener(HandleAdvanceClicked);
button.onClick.AddListener(HandleAdvanceClicked);
}
private void HandleAdvanceClicked()
{
advanceCallback?.Invoke();
}
private void TryAssignCanvasCamera()
{
Camera foundCamera = null;
Camera[] cameras = Camera.allCameras;
@@ -55,22 +191,87 @@ public class galPrefab : MonoBehaviour
{
foundCamera = camObjs[0];
}
camObjs = null; // release temporary reference
}
if (foundCamera == null)
foundCamera = Camera.main;
if (foundCamera != null)
{
Canvas parentCanvas = GetComponentInParent<Canvas>();
if (parentCanvas != null)
{
parentCanvas.worldCamera = foundCamera;
}
foundCamera = Camera.main;
}
// release temporary reference
cameras = null;
if (foundCamera == null)
{
return;
}
Canvas parentCanvas = GetComponentInParent<Canvas>();
if (parentCanvas != null)
{
parentCanvas.worldCamera = foundCamera;
}
}
private static void SetActiveSafe(GameObject target, bool active)
{
if (target != null)
{
target.SetActive(active);
}
}
private static void SetButtonEnabled(Button button, bool enabled)
{
if (button == null)
{
return;
}
button.interactable = enabled;
if (button.gameObject.activeSelf != enabled)
{
button.gameObject.SetActive(enabled);
}
}
private static void ApplyText(TextMeshProUGUI target, string text, Color color)
{
if (target == null)
{
return;
}
target.text = text ?? string.Empty;
target.color = color;
}
private static void ApplyImage(Image target, Sprite sprite, Color color, bool enabled)
{
if (target == null)
{
return;
}
target.enabled = enabled;
target.sprite = sprite;
target.color = color;
}
private static void ApplyPortrait(Image target, Sprite sprite, bool visible, bool flipX)
{
if (target == null)
{
return;
}
target.enabled = visible && sprite != null;
target.sprite = sprite;
RectTransform rect = target.rectTransform;
if (rect != null)
{
Vector3 scale = rect.localScale;
float absX = Mathf.Abs(scale.x);
scale.x = flipX ? -absX : absX;
rect.localScale = scale;
}
}
}
+516 -11
View File
@@ -1,28 +1,533 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public class gameplayGalgame : MonoBehaviour
{
[Header("enable galgame so")]
private ingame_galgame_so.JsonDefinition resolvedDefinition;
private sealed class RuntimeDialogueEntry
{
public int sequence;
public ingame_galgame_so.DialogueElement.PositionTag positionTag;
public ingame_galgame_so.DialogueText dialogue;
public Speaker speaker;
}
[Header("启用开关")]
public bool enableGalgame = false;
public bool enableLyricsSO = true;
[Header("gal so")]
[Header("对话数据")]
public ingame_galgame_so golSO;
[Header("prefabs")]
[Header("预制体")]
public GameObject galgamePrefab;
public GameObject where_to_put;
private string timeType;
private string triggerType;
private string timelineStandard;
[Header("时间轴")]
public AudioSource musicTimelineSource;
[Header("输入")]
public bool allowGlobalClickToAdvance = true;
public KeyCode keyboardAdvanceKey = KeyCode.Space;
public KeyCode keyboardAdvanceKeyAlt = KeyCode.Return;
private readonly List<RuntimeDialogueEntry> runtimeEntries = new List<RuntimeDialogueEntry>();
private galPrefab galController;
private GameObject galInstance;
private int currentEntryIndex = -1;
private bool isRunning;
private bool waitingForClick;
private bool pauseQueueRequested;
private bool entryVisible;
private bool advanceRequested;
private float sceneStartRealtime;
private float entryShownRealtime;
private float customTimelineTime;
private float cachedTimeScale = 1f;
private bool timeActionApplied;
public bool IsRunning => isRunning;
public bool IsPausedQueue => pauseQueueRequested;
public bool HasActiveEntry => isRunning && currentEntryIndex >= 0 && currentEntryIndex < runtimeEntries.Count;
private void Awake()
{
sceneStartRealtime = Time.unscaledTime;
}
private void Start()
{
TryPrepareRuntime();
if (ShouldAutoStart())
{
StartSequence();
}
}
private void Update()
{
if (!isRunning || golSO == null || runtimeEntries.Count == 0)
{
return;
}
if (golSO.timelineStandard == ingame_galgame_so.TimelineBase.CustomTimer)
{
customTimelineTime += Time.unscaledDeltaTime;
}
if (pauseQueueRequested)
{
if (advanceRequested || DetectAdvanceInput())
{
advanceRequested = false;
ResumeSequence();
}
return;
}
RuntimeDialogueEntry entry = GetCurrentEntry();
if (entry == null)
{
FinishSequence();
return;
}
if (!entryVisible)
{
if (GetTimelineTime() >= Mathf.Max(0f, entry.dialogue.appearTime))
{
ShowCurrentEntry(entry);
}
return;
}
if (waitingForClick)
{
if (advanceRequested || DetectAdvanceInput())
{
advanceRequested = false;
ResolveCurrentEntry(entry);
}
return;
}
float requiredDuration = Mathf.Max(0f, entry.dialogue.duration);
if (Time.unscaledTime - entryShownRealtime >= requiredDuration)
{
ResolveCurrentEntry(entry);
}
}
public void read_gol_so()
{
if (golSO != null)
if (golSO == null)
{
timeType = golSO.dialogueType.ToString();
triggerType = golSO.triggerMethod.ToString();
timelineStandard = golSO.timelineStandard.ToString();
Debug.LogWarning("[gameplayGalgame] 没有配置 galgame SO。");
return;
}
else Debug.LogWarning("no gol so");
ResolveDefinition();
if (resolvedDefinition == null)
{
Debug.LogWarning("[gameplayGalgame] 无法解析 galgame 配置。");
return;
}
Debug.Log($"[gameplayGalgame] dialogueType={resolvedDefinition.dialogueType}, triggerMethod={resolvedDefinition.triggerMethod}, timeline={resolvedDefinition.timelineStandard}");
}
public void StartSequence()
{
if (!ShouldPlayConfiguredSo())
{
return;
}
TryPrepareRuntime();
if (golSO == null || runtimeEntries.Count == 0)
{
return;
}
StopSequenceInternal(false);
sceneStartRealtime = Time.unscaledTime;
customTimelineTime = 0f;
currentEntryIndex = 0;
isRunning = true;
waitingForClick = false;
pauseQueueRequested = false;
entryVisible = false;
advanceRequested = false;
EnsureGalInstance();
if (galController != null)
{
galController.HideAllModes();
}
}
public void RestartSequence()
{
StartSequence();
}
public void ResumeSequence()
{
if (!pauseQueueRequested)
{
return;
}
pauseQueueRequested = false;
AdvanceToNextEntry();
}
public void StopSequence()
{
StopSequenceInternal(true);
}
public void RequestAdvance()
{
advanceRequested = true;
}
public void SetCustomTimelineTime(float value)
{
customTimelineTime = Mathf.Max(0f, value);
}
public void AdvanceCustomTimeline(float delta)
{
customTimelineTime = Mathf.Max(0f, customTimelineTime + delta);
}
private bool ShouldAutoStart()
{
if (!ShouldPlayConfiguredSo() || golSO == null)
{
return false;
}
ResolveDefinition();
if (resolvedDefinition == null)
{
return false;
}
return resolvedDefinition.triggerMethod == ingame_galgame_so.TriggerMethod.TimerTrigger
|| resolvedDefinition.triggerMethod == ingame_galgame_so.TriggerMethod.MixedTrigger;
}
private bool ShouldPlayConfiguredSo()
{
if (golSO == null)
{
return false;
}
ResolveDefinition();
if (resolvedDefinition == null)
{
return false;
}
if (resolvedDefinition.dialogueType == ingame_galgame_so.DialogueType.Galgame)
{
return enableGalgame;
}
if (resolvedDefinition.dialogueType == ingame_galgame_so.DialogueType.Lyrics)
{
return enableLyricsSO;
}
return false;
}
private void TryPrepareRuntime()
{
ResolveDefinition();
BuildRuntimeEntries();
EnsureGalInstance();
}
private void BuildRuntimeEntries()
{
runtimeEntries.Clear();
if (golSO == null || resolvedDefinition == null || resolvedDefinition.dialogueList == null)
{
return;
}
int sequence = 0;
for (int i = 0; i < resolvedDefinition.dialogueList.Count; i++)
{
ingame_galgame_so.DialogueElement element = resolvedDefinition.dialogueList[i];
if (element == null || element.textList == null)
{
continue;
}
for (int j = 0; j < element.textList.Count; j++)
{
ingame_galgame_so.DialogueText text = element.textList[j];
if (text == null)
{
continue;
}
runtimeEntries.Add(new RuntimeDialogueEntry
{
sequence = sequence++,
positionTag = element.positionTag,
dialogue = text,
speaker = ResolveSpeaker(text.senderIndex)
});
}
}
}
private Speaker ResolveSpeaker(int senderIndex)
{
if (golSO == null || golSO.speakersDataSO == null || golSO.speakersDataSO.speakers == null)
{
return null;
}
if (senderIndex < 0 || senderIndex >= golSO.speakersDataSO.speakers.Count)
{
return null;
}
return golSO.speakersDataSO.speakers[senderIndex];
}
private void EnsureGalInstance()
{
if (galController != null)
{
galController.Initialize(RequestAdvance);
return;
}
if (galgamePrefab == null)
{
return;
}
Transform parent = where_to_put != null ? where_to_put.transform : transform;
if (galInstance == null)
{
galInstance = Instantiate(galgamePrefab, parent, false);
}
galController = galInstance != null ? galInstance.GetComponent<galPrefab>() : null;
if (galController != null)
{
galController.Initialize(RequestAdvance);
}
}
private RuntimeDialogueEntry GetCurrentEntry()
{
if (currentEntryIndex < 0 || currentEntryIndex >= runtimeEntries.Count)
{
return null;
}
return runtimeEntries[currentEntryIndex];
}
private void ShowCurrentEntry(RuntimeDialogueEntry entry)
{
if (entry == null)
{
return;
}
EnsureGalInstance();
RestoreTimeAction();
if (galController != null)
{
galController.Present(entry.positionTag, entry.dialogue, entry.speaker);
bool clickToNext = entry.dialogue.stepMethod == ingame_galgame_so.DialogueText.StepMethod.ClickToNext;
galController.SetAdvanceEnabled(clickToNext);
}
ApplyTimeAction(entry.dialogue);
entryVisible = true;
entryShownRealtime = Time.unscaledTime;
waitingForClick = entry.dialogue.stepMethod == ingame_galgame_so.DialogueText.StepMethod.ClickToNext;
}
private void ResolveCurrentEntry(RuntimeDialogueEntry entry)
{
if (entry == null)
{
FinishSequence();
return;
}
RestoreTimeAction();
waitingForClick = false;
entryVisible = false;
switch (entry.dialogue.endAction)
{
case ingame_galgame_so.DialogueText.EndAction.NextText:
AdvanceToNextEntry();
break;
case ingame_galgame_so.DialogueText.EndAction.PauseQueue:
pauseQueueRequested = true;
if (galController != null)
{
galController.SetAdvanceEnabled(true);
}
break;
case ingame_galgame_so.DialogueText.EndAction.EndPerformance:
FinishSequence();
break;
default:
AdvanceToNextEntry();
break;
}
}
private void AdvanceToNextEntry()
{
currentEntryIndex++;
if (currentEntryIndex >= runtimeEntries.Count)
{
FinishSequence();
return;
}
advanceRequested = false;
waitingForClick = false;
entryVisible = false;
}
private void FinishSequence()
{
StopSequenceInternal(true);
}
private void StopSequenceInternal(bool hideUi)
{
RestoreTimeAction();
isRunning = false;
waitingForClick = false;
pauseQueueRequested = false;
entryVisible = false;
advanceRequested = false;
currentEntryIndex = -1;
if (hideUi && galController != null)
{
galController.HideAllModes();
galController.SetAdvanceEnabled(false);
}
}
private void ApplyTimeAction(ingame_galgame_so.DialogueText dialogue)
{
if (dialogue == null || dialogue.timeAction == ingame_galgame_so.DialogueText.TimeAction.None)
{
return;
}
cachedTimeScale = Time.timeScale;
timeActionApplied = true;
switch (dialogue.timeAction)
{
case ingame_galgame_so.DialogueText.TimeAction.SlowMotion:
Time.timeScale = Mathf.Clamp(dialogue.slowMotionScale, 0f, 1f);
break;
case ingame_galgame_so.DialogueText.TimeAction.Pause:
Time.timeScale = 0f;
break;
}
}
private void RestoreTimeAction()
{
if (!timeActionApplied)
{
return;
}
Time.timeScale = cachedTimeScale;
timeActionApplied = false;
}
private float GetTimelineTime()
{
if (golSO == null)
{
return 0f;
}
ResolveDefinition();
if (resolvedDefinition == null)
{
return 0f;
}
switch (resolvedDefinition.timelineStandard)
{
case ingame_galgame_so.TimelineBase.SceneStartTime:
return Mathf.Max(0f, Time.unscaledTime - sceneStartRealtime);
case ingame_galgame_so.TimelineBase.CustomTimer:
return customTimelineTime;
case ingame_galgame_so.TimelineBase.MusicTime:
if (musicTimelineSource != null)
{
return Mathf.Max(0f, musicTimelineSource.time);
}
return Mathf.Max(0f, Time.unscaledTime - sceneStartRealtime);
default:
return Mathf.Max(0f, Time.unscaledTime - sceneStartRealtime);
}
}
private void ResolveDefinition()
{
resolvedDefinition = golSO != null ? golSO.GetResolvedDefinition() : null;
}
private bool DetectAdvanceInput()
{
if (!allowGlobalClickToAdvance)
{
return false;
}
if (Input.GetMouseButtonDown(0))
{
return true;
}
if (Input.touchCount > 0)
{
Touch touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Began)
{
return true;
}
}
return Input.GetKeyDown(keyboardAdvanceKey) || Input.GetKeyDown(keyboardAdvanceKeyAlt);
}
}
+7 -6
View File
@@ -171,7 +171,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 179.685, y: -24.015}
m_AnchoredPosition: {x: 129.685, y: -24.015}
m_SizeDelta: {x: 159.37, y: 24.01}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1904443238537391023
@@ -327,7 +327,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 179.685, y: -6.005}
m_AnchoredPosition: {x: 129.685, y: -6.005}
m_SizeDelta: {x: 5.48, y: 12.01}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7988485425920675964
@@ -1393,7 +1393,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 359.37, y: 48.03}
m_SizeDelta: {x: 259.37, y: 48.03}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4601708949971673813
CanvasRenderer:
@@ -1446,8 +1446,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 100
m_Right: 100
m_Left: 50
m_Right: 50
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 4
@@ -2228,7 +2228,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 179.685, y: -42.025}
m_AnchoredPosition: {x: 129.685, y: -42.025}
m_SizeDelta: {x: 5.48, y: 12.01}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8766812421281384592
@@ -2743,6 +2743,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6c868a66b282da94faaf38c62d26fcbe, type: 3}
m_Name:
m_EditorClassIdentifier:
prefabCanvas: {fileID: 8228997081257688641}
nowUsing: 0
defaultTextColor: {r: 1, g: 1, b: 1, a: 1}
roleHostBGbar: {fileID: 662360290209903647}
+291 -44
View File
@@ -1,79 +1,326 @@
using UnityEngine;
using System;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "NewGalSO", menuName = "Galgame/galSO")]
public class ingame_galgame_so : ScriptableObject
{
[System.Serializable]
[Serializable]
public class DialogueText
{
public enum ImagePosition
{
Left,
Right
}
public enum StepMethod
{
ClickToNext,
WaitForDuration
}
public enum TimeAction
{
None,
SlowMotion,
Pause
}
public enum EndAction
{
NextText,
PauseQueue,
EndPerformance
}
[TextArea(3, 10)]
[Tooltip("文本内容")]
public string content; // 文本内容
[Tooltip("当前对话实际显示的文本内容")]
public string content;
[Tooltip("队列中第几个文本")]
public int textNumber; // 队列中第几个文本
[Tooltip("文本编号,仅用于人工整理,不作为运行时唯一依据。")]
public int textNumber;
[Tooltip(" speakersDataSO 中选择发言者")]
public int senderIndex = -1; // 改为索引,通过下拉选择
[Tooltip("发言人索引,来自 speakersDataSO 的 speakers 列表。-1 表示系统或旁白。")]
public int senderIndex = -1;
public enum ImagePosition { Left, Right }
[Tooltip("对象图片左右位置")]
public ImagePosition imagePos; // 对象图片左右位置
[Tooltip("对象图片是否水平翻转")]
[Tooltip("角色图片显示在左侧还是右侧。")]
public ImagePosition imagePos = ImagePosition.Left;
[Tooltip("角色图片是否水平翻转")]
public bool flipX;
[Tooltip("文本出现时间")]
public float appearTime; // 文本出现时间
[Tooltip("文本持续时间")]
public float duration; // 文本持续时间
[Tooltip("该条文本在所选时间轴上的出现时间")]
public float appearTime;
public enum StepMethod { ClickToNext, WaitForDuration }
[Tooltip("文本步进方法:点击后下一步 / 等待时长结束")]
public StepMethod stepMethod; // 文本步进方法
[Tooltip("自动播放时的停留时间,仅在 WaitForDuration 下生效。")]
public float duration = 1f;
public enum TimeAction { None, SlowMotion, Pause }
[Tooltip("文本出现时动作:无/慢动作/暂停")]
public TimeAction timeAction; // 文本出现时动作
[Tooltip("当前文本如何推进到下一条。")]
public StepMethod stepMethod = StepMethod.ClickToNext;
[Tooltip("文本播放期间时间流速,0为暂停")]
[Tooltip("文本播放期间对游戏时间流做的动作。")]
public TimeAction timeAction = TimeAction.None;
[Tooltip("当 timeAction 为 SlowMotion 时使用的 Time.timeScale。")]
[Range(0f, 1f)]
public float slowMotionScale = 0.5f; // 慢动作允许TimeScale设置值
public float slowMotionScale = 0.5f;
public enum EndAction { NextText, PauseQueue, EndPerformance }
[Tooltip("文本结束动作")]
public EndAction endAction; // 文本结束动作
[Tooltip("当前文本结束后的队列行为。")]
public EndAction endAction = EndAction.NextText;
public DialogueText Clone()
{
return new DialogueText
{
content = content,
textNumber = textNumber,
senderIndex = senderIndex,
imagePos = imagePos,
flipX = flipX,
appearTime = appearTime,
duration = duration,
stepMethod = stepMethod,
timeAction = timeAction,
slowMotionScale = slowMotionScale,
endAction = endAction
};
}
}
[System.Serializable]
[Serializable]
public class DialogueElement
{
public enum PositionTag { RoleHost, RoleHint, Narration, HintOrLyrics }
public enum PositionTag
{
RoleHost,
RoleHint,
Narration,
HintOrLyrics
}
[Header("显示模式")]
[Tooltip("决定本段文本使用哪种对话框样式。")]
public PositionTag positionTag = PositionTag.RoleHost;
[Header("位置配置")]
public PositionTag positionTag;
[HideInInspector]
public List<Vector2> customPositions;
public List<Vector2> customPositions = new List<Vector2>();
[Header("文本内容配置")]
public List<DialogueText> textList; // 文字列表
[Header("文本列表")]
[Tooltip("该段落下的实际文本播放列表。")]
public List<DialogueText> textList = new List<DialogueText>();
public DialogueElement Clone()
{
var clone = new DialogueElement
{
positionTag = positionTag,
customPositions = customPositions != null ? new List<Vector2>(customPositions) : new List<Vector2>(),
textList = new List<DialogueText>()
};
if (textList != null)
{
for (int i = 0; i < textList.Count; i++)
{
if (textList[i] != null)
{
clone.textList.Add(textList[i].Clone());
}
}
}
return clone;
}
}
public enum TimelineBase { MusicTime, SceneStartTime, CustomTimer }
public enum TriggerMethod { CodeTrigger, TimerTrigger, MixedTrigger }
public enum DialogueType { Galgame, Lyrics }
public enum TimelineBase
{
MusicTime,
SceneStartTime,
CustomTimer
}
public enum TriggerMethod
{
CodeTrigger,
TimerTrigger,
MixedTrigger
}
public enum DialogueType
{
Galgame,
Lyrics
}
[Serializable]
public class JsonDefinition
{
public int version = 1;
public DialogueType dialogueType = DialogueType.Galgame;
public TriggerMethod triggerMethod = TriggerMethod.TimerTrigger;
public TimelineBase timelineStandard = TimelineBase.SceneStartTime;
public List<DialogueElement> dialogueList = new List<DialogueElement>();
public JsonDefinition Clone()
{
var clone = new JsonDefinition
{
version = version,
dialogueType = dialogueType,
triggerMethod = triggerMethod,
timelineStandard = timelineStandard,
dialogueList = new List<DialogueElement>()
};
if (dialogueList != null)
{
for (int i = 0; i < dialogueList.Count; i++)
{
if (dialogueList[i] != null)
{
clone.dialogueList.Add(dialogueList[i].Clone());
}
}
}
return clone;
}
}
[Header("全局配置")]
[Tooltip("对话类型")]
public DialogueType dialogueType;
[Tooltip("触发方式")]
public TriggerMethod triggerMethod;
[Tooltip("时间线基准")]
public TimelineBase timelineStandard;
[Tooltip("当前脚本化演出是普通对话还是歌词模式。")]
public DialogueType dialogueType = DialogueType.Galgame;
[Tooltip("运行时由代码触发、按时间轴触发,还是两者混合。")]
public TriggerMethod triggerMethod = TriggerMethod.TimerTrigger;
[Tooltip("appearTime 使用哪一种时间基准。")]
public TimelineBase timelineStandard = TimelineBase.SceneStartTime;
[Header("角色数据")]
[Tooltip("引用 Speaker 配置 ScriptableObject")]
[Tooltip("发言人配置来源。")]
public galgame_speakers_so speakersDataSO;
[Header("JSON 覆盖")]
[Tooltip("如果拖入 JSON 文本资源,运行时会优先使用 JSON 内容,而不是当前 Inspector 里的对话配置。")]
public TextAsset jsonDefinitionAsset;
[Header("对话内容")]
public List<DialogueElement> dialogueList = new List<DialogueElement>();
public bool HasJsonOverride => jsonDefinitionAsset != null && !string.IsNullOrWhiteSpace(jsonDefinitionAsset.text);
public JsonDefinition BuildDefinitionFromInspector()
{
var definition = new JsonDefinition
{
dialogueType = dialogueType,
triggerMethod = triggerMethod,
timelineStandard = timelineStandard,
dialogueList = new List<DialogueElement>()
};
if (dialogueList != null)
{
for (int i = 0; i < dialogueList.Count; i++)
{
if (dialogueList[i] != null)
{
definition.dialogueList.Add(dialogueList[i].Clone());
}
}
}
return definition;
}
public bool TryParseJsonOverride(out JsonDefinition definition)
{
definition = null;
if (!HasJsonOverride)
{
return false;
}
try
{
definition = JsonUtility.FromJson<JsonDefinition>(jsonDefinitionAsset.text);
if (definition == null)
{
return false;
}
if (definition.dialogueList == null)
{
definition.dialogueList = new List<DialogueElement>();
}
return true;
}
catch (Exception ex)
{
Debug.LogWarning($"[ingame_galgame_so] JSON 解析失败: {ex.Message}", this);
definition = null;
return false;
}
}
public JsonDefinition GetResolvedDefinition()
{
if (TryParseJsonOverride(out JsonDefinition fromJson))
{
return fromJson;
}
return BuildDefinitionFromInspector();
}
public string ExportCurrentDefinitionToJson(bool prettyPrint = true)
{
return JsonUtility.ToJson(BuildDefinitionFromInspector(), prettyPrint);
}
public void ApplyDefinitionToInspector(JsonDefinition definition)
{
if (definition == null)
{
return;
}
dialogueType = definition.dialogueType;
triggerMethod = definition.triggerMethod;
timelineStandard = definition.timelineStandard;
dialogueList ??= new List<DialogueElement>();
dialogueList.Clear();
if (definition.dialogueList == null)
{
return;
}
for (int i = 0; i < definition.dialogueList.Count; i++)
{
DialogueElement element = definition.dialogueList[i];
if (element != null)
{
dialogueList.Add(element.Clone());
}
}
}
public bool TryApplyJsonOverrideToInspector(out string errorMessage)
{
errorMessage = string.Empty;
if (!TryParseJsonOverride(out JsonDefinition definition))
{
errorMessage = HasJsonOverride ? "JSON 解析失败" : "未配置 JSON 覆盖源";
return false;
}
ApplyDefinitionToInspector(definition);
return true;
}
}
+19 -4
View File
@@ -16,21 +16,22 @@ MonoBehaviour:
triggerMethod: 1
timelineStandard: 0
speakersDataSO: {fileID: 11400000, guid: 8e500b367b7861f44897e5396b1989ce, type: 2}
jsonDefinitionAsset: {fileID: 4900000, guid: 59e1b7a6ebe2596419c72f27a80cec9a, type: 3}
dialogueList:
- positionTag: 0
customPositions: []
textList:
- content: 1
- content: "\u4F60\u597D"
textNumber: 1
senderIndex: 0
senderIndex: 2
imagePos: 0
flipX: 0
appearTime: 0
duration: 0
duration: 5
stepMethod: 1
timeAction: 0
slowMotionScale: 0
endAction: 0
endAction: 2
- positionTag: 0
customPositions: []
textList:
@@ -73,3 +74,17 @@ MonoBehaviour:
timeAction: 0
slowMotionScale: 0
endAction: 0
- positionTag: 0
customPositions: []
textList:
- content: 4
textNumber: 1
senderIndex: -1
imagePos: 0
flipX: 0
appearTime: 0
duration: 0
stepMethod: 0
timeAction: 0
slowMotionScale: 0
endAction: 0
+6 -3
View File
@@ -18,16 +18,19 @@ MonoBehaviour:
spkrName: SystemBG
spkr_themeColor: {r: 0, g: 0, b: 0, a: 0}
spkrDescription: "\u7CFB\u7EDF\u65C1\u767D"
spkrSprite: {fileID: 0}
spkrHD_Sprite: {fileID: 0}
spkrProfile_Sprite: {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}
spkrHD_Sprite: {fileID: 0}
spkrProfile_Sprite: {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}
spkrHD_Sprite: {fileID: 21300000, guid: 1a757eef01620424883e7d20aa232463, type: 3}
spkrProfile_Sprite: {fileID: 21300000, guid: 1a62adf36834dd04181a6dd61344f8b8, type: 3}
@@ -13,16 +13,4 @@ public class skill_detail_prefab_inHeroDetail : MonoBehaviour
public Sprite skill_slot_available_image;
public Sprite skill_slot_unavailable_image;
public Sprite skill_slot_locked_image;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
+125
View File
@@ -0,0 +1,125 @@
<linker>
<assembly fullname="Assembly-CSharp">
<type fullname="GameServer.Client.WsMessage" preserve="all" />
<type fullname="GameServer.Client.WsMessage`1" preserve="all" />
<type fullname="GameServer.Client.HandshakeRequest" preserve="all" />
<type fullname="GameServer.Client.HandshakeResponse" preserve="all" />
<type fullname="GameServer.Client.AvatarUploadResponse" preserve="all" />
<type fullname="GameServer.Client.SteamFriendsImportRequest" preserve="all" />
<type fullname="GameServer.Client.SteamFriendsImportResponse" preserve="all" />
<type fullname="GameServer.Client.ProfileData" preserve="all" />
<type fullname="GameServer.Client.LeaderboardEntry" preserve="all" />
<type fullname="GameServer.Client.LeaderboardData" preserve="all" />
<type fullname="GameServer.Client.ScorePushRequest" preserve="all" />
<type fullname="GameServer.Client.ScoreAckResponse" preserve="all" />
<type fullname="GameServer.Client.ArenaCreateRequest" preserve="all" />
<type fullname="GameServer.Client.ArenaCreateResponse" preserve="all" />
<type fullname="GameServer.Client.ArenaJoinRequest" preserve="all" />
<type fullname="GameServer.Client.ArenaJoinResponse" preserve="all" />
<type fullname="GameServer.Client.ArenaStartRequest" preserve="all" />
<type fullname="GameServer.Client.ArenaStartResponse" preserve="all" />
<type fullname="GameServer.Client.ArenaSubmitRequest" preserve="all" />
<type fullname="GameServer.Client.ArenaResultEntry" preserve="all" />
<type fullname="GameServer.Client.ArenaResult" preserve="all" />
<type fullname="GameServer.Client.HeartbeatResponse" preserve="all" />
<type fullname="GameServer.Client.ErrorResponse" preserve="all" />
<type fullname="GameServer.Client.ArenaRoomParticipant" preserve="all" />
<type fullname="GameServer.Client.ArenaRoomSnapshot" preserve="all" />
<type fullname="GameServer.Client.ArenaSubmittedScore" preserve="all" />
<type fullname="GameServer.Client.ArenaRoomChatMessage" preserve="all" />
<type fullname="GameServer.Client.ArenaRoomHistoryData" preserve="all" />
<type fullname="GameServer.Client.SocialWorldHistoryData" preserve="all" />
<type fullname="GameServer.Client.SocialPrivateHistoryData" preserve="all" />
<type fullname="GameServer.Client.SocialFriendEntry" preserve="all" />
<type fullname="GameServer.Client.SocialFriendsListData" preserve="all" />
<type fullname="GameServer.Client.SocialFriendsApiResponse" preserve="all" />
<type fullname="GameServer.Client.MailApiRewardEntry" preserve="all" />
<type fullname="GameServer.Client.MailApiEntry" preserve="all" />
<type fullname="GameServer.Client.MailApiDeletionEntry" preserve="all" />
<type fullname="GameServer.Client.MailApiVersionResponse" preserve="all" />
<type fullname="GameServer.Client.MailApiListResponse" preserve="all" />
<type fullname="GameServer.Client.MailClaimRequest" preserve="all" />
<type fullname="GameServer.Client.MailClaimResponse" preserve="all" />
<type fullname="GameServer.Client.SocialPresenceUpdateData" preserve="all" />
<type fullname="GameServer.Client.SocialFriendRequestEntry" preserve="all" />
<type fullname="GameServer.Client.SocialFriendRequestsListData" preserve="all" />
<type fullname="WebViewObject" preserve="all" />
<type fullname="WebViewWin32" preserve="all" />
<type fullname="SongButton" preserve="all" />
<type fullname="Player_SO" preserve="all" />
</assembly>
<assembly fullname="EasyChart.Runtime">
<type fullname="EasyChart.ChartFeed" preserve="all" />
<type fullname="EasyChart.AxisFeed" preserve="all" />
<type fullname="EasyChart.SerieFeed" preserve="all" />
<type fullname="EasyChart.DataFeed" preserve="all" />
<type fullname="EasyChart.ChartProfile" preserve="all" />
<type fullname="EasyChart.ChartTheme" preserve="all" />
<type fullname="EasyChart.ChartThemeRegistry" preserve="all" />
<type fullname="EasyChart.ChartJsonUtils" preserve="all" />
<type fullname="EasyChart.ProPackage" preserve="all" />
<type fullname="EasyChart.ChartTextStyleApplier" preserve="all" />
<type fullname="EasyChart.CartesianMapping" preserve="all" />
<type fullname="EasyChart.PlotLayoutSettings" preserve="all" />
<type fullname="EasyChart.LabelStyleSettings" preserve="all" />
<type fullname="EasyChart.AxisConfig" preserve="all" />
<type fullname="EasyChart.PointSettings" preserve="all" />
<type fullname="EasyChart.TextureMappingSettings" preserve="all" />
<type fullname="EasyChart.TextureFillSettings" preserve="all" />
<type fullname="EasyChart.SeriesData" preserve="all" />
<type fullname="EasyChart.SizeMappingSettings" preserve="all" />
<type fullname="EasyChart.HoverHighlightSettings" preserve="all" />
<type fullname="EasyChart.BarHoverSettings" preserve="all" />
<type fullname="EasyChart.LineStrokeSettings" preserve="all" />
<type fullname="EasyChart.AreaFillSettings" preserve="all" />
<type fullname="EasyChart.BorderSettings" preserve="all" />
<type fullname="EasyChart.BackgroundSettings" preserve="all" />
<type fullname="EasyChart.LineSettings" preserve="all" />
<type fullname="EasyChart.ScatterSettings" preserve="all" />
<type fullname="EasyChart.HeatmapSettings" preserve="all" />
<type fullname="EasyChart.HeatmapSettings+BleedSettings" preserve="all" />
<type fullname="EasyChart.HeatmapSettings+SmoothSettings" preserve="all" />
<type fullname="EasyChart.HeatmapSettings+GradientSettings" preserve="all" />
<type fullname="EasyChart.HeatmapSettings+ContourSettings" preserve="all" />
<type fullname="EasyChart.RadarSettings" preserve="all" />
<type fullname="EasyChart.RadarSettings+RadarLayoutSettings" preserve="all" />
<type fullname="EasyChart.BarSettings" preserve="all" />
<type fullname="EasyChart.PieLayoutSettings" preserve="all" />
<type fullname="EasyChart.RingSettings" preserve="all" />
<type fullname="EasyChart.PieLegendSettings" preserve="all" />
<type fullname="EasyChart.PieSettings" preserve="all" />
<type fullname="EasyChart.RingChartLayoutSettings" preserve="all" />
<type fullname="EasyChart.RingValueMappingSettings" preserve="all" />
<type fullname="EasyChart.RingChartSettings" preserve="all" />
<type fullname="EasyChart.PieHoverSettings" preserve="all" />
<type fullname="EasyChart.PieAggregationSettings" preserve="all" />
<type fullname="EasyChart.SerieLabelSettings" preserve="all" />
<type fullname="EasyChart.LegendSettings" preserve="all" />
<type fullname="EasyChart.PlotSettings" preserve="all" />
<type fullname="EasyChart.CartesianGridSettings" preserve="all" />
<type fullname="EasyChart.HoverSettings" preserve="all" />
<type fullname="EasyChart.PolarAxisStyle" preserve="all" />
<type fullname="EasyChart.PolarAxesSettings" preserve="all" />
<type fullname="EasyChart.ChartData" preserve="all" />
<type fullname="EasyChart.Serie" preserve="all" />
</assembly>
<assembly fullname="MCPForUnity.Runtime">
<type fullname="MCPForUnity.Runtime.Serialization.Vector3Converter" preserve="all" />
<type fullname="MCPForUnity.Runtime.Serialization.Vector2Converter" preserve="all" />
<type fullname="MCPForUnity.Runtime.Serialization.QuaternionConverter" preserve="all" />
<type fullname="MCPForUnity.Runtime.Serialization.ColorConverter" preserve="all" />
<type fullname="MCPForUnity.Runtime.Serialization.RectConverter" preserve="all" />
<type fullname="MCPForUnity.Runtime.Serialization.BoundsConverter" preserve="all" />
<type fullname="MCPForUnity.Runtime.Serialization.Vector4Converter" preserve="all" />
<type fullname="MCPForUnity.Runtime.Serialization.Matrix4x4Converter" preserve="all" />
<type fullname="MCPForUnity.Runtime.Serialization.UnityEngineObjectConverter" preserve="all" />
</assembly>
<assembly fullname="UnityEngine.UIElementsModule">
<type fullname="UnityEngine.UIElements.StyleFontDefinition" preserve="all" />
<type fullname="UnityEngine.UIElements.FontDefinition" preserve="all" />
</assembly>
</linker>
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fb689a3a02fa5e942bac14f5f49deec4
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+5
View File
@@ -32,6 +32,9 @@ public class mail_so : ScriptableObject
expBottles_allies,
money,
metarial,
growth_material,
equipment_consumable,
store_item,
package,
}
@@ -43,5 +46,7 @@ public class mail_so : ScriptableObject
public int reward_ammount;
public Sprite reward_image;
public string reward_description;
public string reward_key;
public int reward_store_item_id;
}
}
+103
View File
@@ -0,0 +1,103 @@
{
"version": 1,
"dialogueType": 0,
"triggerMethod": 1,
"timelineStandard": 0,
"dialogueList": [
{
"positionTag": 0,
"customPositions": [],
"textList": [
{
"content": "你好",
"textNumber": 1,
"senderIndex": 2,
"imagePos": 0,
"flipX": false,
"appearTime": 0.0,
"duration": 5.0,
"stepMethod": 1,
"timeAction": 0,
"slowMotionScale": 0.0,
"endAction": 2
}
]
},
{
"positionTag": 0,
"customPositions": [],
"textList": [
{
"content": "2",
"textNumber": 1,
"senderIndex": 0,
"imagePos": 0,
"flipX": false,
"appearTime": 0.0,
"duration": 0.0,
"stepMethod": 0,
"timeAction": 0,
"slowMotionScale": 0.0,
"endAction": 0
}
]
},
{
"positionTag": 0,
"customPositions": [],
"textList": [
{
"content": "3",
"textNumber": 1,
"senderIndex": 0,
"imagePos": 0,
"flipX": false,
"appearTime": 0.0,
"duration": 0.0,
"stepMethod": 1,
"timeAction": 0,
"slowMotionScale": 0.0,
"endAction": 0
}
]
},
{
"positionTag": 0,
"customPositions": [],
"textList": [
{
"content": "4",
"textNumber": 1,
"senderIndex": -1,
"imagePos": 0,
"flipX": false,
"appearTime": 0.0,
"duration": 0.0,
"stepMethod": 0,
"timeAction": 0,
"slowMotionScale": 0.0,
"endAction": 0
}
]
},
{
"positionTag": 0,
"customPositions": [],
"textList": [
{
"content": "4",
"textNumber": 1,
"senderIndex": -1,
"imagePos": 0,
"flipX": false,
"appearTime": 0.0,
"duration": 0.0,
"stepMethod": 0,
"timeAction": 0,
"slowMotionScale": 0.0,
"endAction": 0
}
]
}
]
}
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 59e1b7a6ebe2596419c72f27a80cec9a
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+3 -3
View File
@@ -262,7 +262,7 @@ public class UI_Player : MonoBehaviour
private static int CountOwnedHeroes()
{
AllyHero_SO[] loadedHeroes = Resources.LoadAll<AllyHero_SO>(string.Empty);
AllyHero_SO[] loadedHeroes = RuntimeResourcesCache.LoadAllAllyHeroes();
HashSet<int> uniqueHeroIds = new HashSet<int>();
int ownedCount = 0;
@@ -289,7 +289,7 @@ public class UI_Player : MonoBehaviour
private static SongStats CollectSongStats()
{
SongData[] songs = Resources.LoadAll<SongData>(SongResourcesPath);
SongData[] songs = RuntimeResourcesCache.LoadSongsFromPath(SongResourcesPath);
HashSet<int> uniqueSongIds = new HashSet<int>();
SongStats stats = new SongStats();
@@ -301,7 +301,7 @@ public class UI_Player : MonoBehaviour
continue;
}
song.LoadPersistent();
song.EnsurePersistentDataLoaded();
if (song.isUnlocked)
{
@@ -343,7 +343,7 @@ public sealed class GlobalAchievementService : MonoBehaviour
StoreOwnershipLedger.EnsureInstance().ForceSyncMirrorFlags();
}
SongData[] songs = Resources.LoadAll<SongData>("song_songIndex");
SongData[] songs = RuntimeResourcesCache.LoadSongsFromPath("song_songIndex");
if (songs == null || songs.Length == 0)
{
bool emptyChanged = false;
@@ -366,7 +366,7 @@ public sealed class GlobalAchievementService : MonoBehaviour
continue;
}
song.LoadPersistent();
song.EnsurePersistentDataLoaded();
if (song.isUnlocked)
{
+1 -1
View File
@@ -1053,7 +1053,7 @@ public class AllyCombatant : MonoBehaviour, ICombatant
private static void EnsureAllyHeroCache()
{
if (cachedAllAllyHeroes != null) return;
cachedAllAllyHeroes = Resources.LoadAll<AllyHero_SO>("") ?? Array.Empty<AllyHero_SO>();
cachedAllAllyHeroes = RuntimeResourcesCache.LoadAllAllyHeroes() ?? Array.Empty<AllyHero_SO>();
}
// Documentation text normalized.
+2 -2
View File
@@ -202,7 +202,7 @@ public class SkillBuilder : MonoBehaviour
{
if (_allAllyHeroSOs != null && _allAllyHeroSOs.Length > 0) return;
_allAllyHeroSOs = Resources.LoadAll<AllyHero_SO>("");
_allAllyHeroSOs = RuntimeResourcesCache.LoadAllAllyHeroes();
_allyHeroSoById = new Dictionary<int, AllyHero_SO>(_allAllyHeroSOs != null ? _allAllyHeroSOs.Length : 0);
_allyHeroSoBySlotCache = new Dictionary<int, AllyHero_SO>(8);
@@ -764,7 +764,7 @@ public class SkillBuilder : MonoBehaviour
else
{
// fallback to previous behavior if index missing
var all = Resources.LoadAll<AllyHero_SO>("");
var all = RuntimeResourcesCache.LoadAllAllyHeroes();
foreach (var a in all)
{
if (a != null && a.ally_heroID == id) { result = a; break; }
+2 -2
View File
@@ -345,7 +345,7 @@ public class AllyHero_SO : ScriptableObject
}
#endif
return Resources.LoadAll<AllyHero_SO>("so/ally");
return RuntimeResourcesCache.LoadAll<AllyHero_SO>("so/ally");
}
private static void TryAddEquipmentSkillGroupId(List<int> result, HashSet<int> dedupe, int groupId)
@@ -678,7 +678,7 @@ public class AllyHero_SO : ScriptableObject
UnityEditor.AssetDatabase.SaveAssets();
#endif
AllyHero_SO[] runtimeHeroes = Resources.LoadAll<AllyHero_SO>("so/ally");
AllyHero_SO[] runtimeHeroes = RuntimeResourcesCache.LoadAll<AllyHero_SO>("so/ally");
for (int i = 0; i < runtimeHeroes.Length; i++)
{
AllyHero_SO hero = runtimeHeroes[i];
+21
View File
@@ -154,6 +154,27 @@ public class Player_SO : ScriptableObject
PersistEditorChanges();
}
public int GetLegacyExpBottleCount(string fieldName)
{
switch (fieldName)
{
case "commonExpBottle78001":
return commonExpBottle78001;
case "mediumExpBottle78002":
return mediumExpBottle78002;
case "superiorExpBottle78003":
return superiorExpBottle78003;
case "supremeExpBottle78004":
return supremeExpBottle78004;
case "extraordinaryExpBottle78005":
return extraordinaryExpBottle78005;
case "celestialExpBottle78006":
return celestialExpBottle78006;
default:
return 0;
}
}
public int GetLegacyDushMaterialCount(string fieldName)
{
switch (fieldName)
@@ -22,6 +22,8 @@ using Steamworks;
[DisallowMultipleComponent]
public class SteamManager : MonoBehaviour {
#if !DISABLESTEAMWORKS
protected const uint SteamAppIdValue = 2191270;
protected static readonly AppId_t SteamAppId = new AppId_t(SteamAppIdValue);
protected static bool s_EverInitialized = false;
protected static SteamManager s_instance;
@@ -96,7 +98,7 @@ public class SteamManager : MonoBehaviour {
// Once you get a Steam AppID assigned by Valve, you need to replace AppId_t.Invalid with it and
// remove steam_appid.txt from the game depot. eg: "(AppId_t)480" or "new AppId_t(480)".
// See the Valve documentation for more information: https://partner.steamgames.com/doc/sdk/api#initialization_and_shutdown
if (SteamAPI.RestartAppIfNecessary(AppId_t.Invalid)) {
if (SteamAPI.RestartAppIfNecessary(SteamAppId)) {
Debug.Log("[Steamworks.NET] Shutting down because RestartAppIfNecessary returned true. Steam will restart the application.");
Application.Quit();
+111
View File
@@ -0,0 +1,111 @@
using UnityEngine;
using UnityEngine.UI;
[ExecuteAlways]
[DisallowMultipleComponent]
[RequireComponent(typeof(Text))]
[RequireComponent(typeof(LayoutElement))]
public sealed class BubbleTextWidthLimiter : MonoBehaviour
{
[Min(1f)]
public float maxPreferredWidth = 224f;
private Text textComponent;
private LayoutElement layoutElement;
private string lastText;
private Font lastFont;
private int lastFontSize;
private FontStyle lastFontStyle;
private float lastMaxPreferredWidth = -1f;
private void Awake()
{
CacheComponents();
Apply();
}
private void OnEnable()
{
CacheComponents();
Apply();
}
private void OnValidate()
{
CacheComponents();
Apply();
}
private void LateUpdate()
{
if (NeedsRefresh())
{
Apply();
}
}
private void CacheComponents()
{
if (textComponent == null)
{
textComponent = GetComponent<Text>();
}
if (layoutElement == null)
{
layoutElement = GetComponent<LayoutElement>();
}
}
private bool NeedsRefresh()
{
if (textComponent == null || layoutElement == null)
{
return false;
}
return lastText != textComponent.text
|| lastFont != textComponent.font
|| lastFontSize != textComponent.fontSize
|| lastFontStyle != textComponent.fontStyle
|| !Mathf.Approximately(lastMaxPreferredWidth, maxPreferredWidth);
}
private void Apply()
{
if (textComponent == null || layoutElement == null)
{
return;
}
textComponent.horizontalOverflow = HorizontalWrapMode.Wrap;
textComponent.verticalOverflow = VerticalWrapMode.Overflow;
var generationSettings = textComponent.GetGenerationSettings(new Vector2(10000f, 0f));
var rawPreferredWidth = textComponent.cachedTextGeneratorForLayout.GetPreferredWidth(textComponent.text ?? string.Empty, generationSettings)
/ textComponent.pixelsPerUnit;
layoutElement.minWidth = 0f;
layoutElement.preferredWidth = Mathf.Min(rawPreferredWidth, Mathf.Max(1f, maxPreferredWidth));
layoutElement.flexibleWidth = -1f;
layoutElement.minHeight = -1f;
layoutElement.preferredHeight = -1f;
layoutElement.flexibleHeight = -1f;
var rectTransform = transform as RectTransform;
if (rectTransform != null)
{
LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
if (rectTransform.parent is RectTransform parentRect)
{
LayoutRebuilder.MarkLayoutForRebuild(parentRect);
}
}
lastText = textComponent.text;
lastFont = textComponent.font;
lastFontSize = textComponent.fontSize;
lastFontStyle = textComponent.fontStyle;
lastMaxPreferredWidth = maxPreferredWidth;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3fb66c09204f49b4bfeb513c894b52e0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
+7
View File
@@ -42,6 +42,8 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
[SerializeField] GameObject ui_Panel_Story;
[SerializeField] Button button_Setting;
[SerializeField] GameObject ui_Panel_Setting;
[SerializeField] Button button_worldChat;
[SerializeField] GameObject worldChatObject;
[SerializeField] float prefab_Enter_Time = 0.35f;
[SerializeField] float prefab_Enter_Scale_From = 0.92f;
[SerializeField] Ease prefab_Enter_Ease = Ease.OutCubic;
@@ -330,6 +332,11 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
if (button_Setting != null)
button_Setting.onClick.AddListener(
() => Try_Open_Panel(ui_Panel_Setting));
if (worldChatObject != null)
worldChatObject.SetActive(false);
if (button_worldChat != null && worldChatObject != null)
button_worldChat.onClick.AddListener(
() => worldChatObject.SetActive(true));
if (button_Select_Music != null)
@@ -3098,7 +3098,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &7476805877805305379
RectTransform:
m_ObjectHideFlags: 0
@@ -3115,10 +3115,10 @@ RectTransform:
- {fileID: 2515611058996813551}
m_Father: {fileID: 7912636600211646566}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 95, y: -25}
m_SizeDelta: {x: 50, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8613954281550256410
CanvasRenderer:
@@ -4105,7 +4105,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &3878110758398832463
RectTransform:
m_ObjectHideFlags: 0
@@ -4121,10 +4121,10 @@ RectTransform:
- {fileID: 2099305528324639673}
m_Father: {fileID: 7912636600211646566}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 25, y: -25}
m_SizeDelta: {x: 50, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2846323317655161991
CanvasRenderer:
@@ -5113,6 +5113,7 @@ MonoBehaviour:
email_prefab: {fileID: 3756075665884320709, guid: 41f4ea31b64f18d48aeef21b79930a6c, type: 3}
notice_prefab: {fileID: 8527835049849151044, guid: 06bb6d3a45697374ab4f5ff36356d138, type: 3}
userBag_prefab: {fileID: 2826375232361138358, guid: 9e0039d3a46af1c458d7f6e2fc72bab2, type: 3}
mailRedPot: {fileID: 5835331043321630532}
back_navButton: {fileID: 0}
home_navButton: {fileID: 0}
settings_navButton: {fileID: 0}
@@ -6126,6 +6127,7 @@ RectTransform:
m_Children:
- {fileID: 7514224236584078014}
- {fileID: 4607317886706537962}
- {fileID: 1145193307346210204}
m_Father: {fileID: 7912636600211646566}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
@@ -6602,6 +6604,81 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &6847515371386411778
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1145193307346210204}
- component: {fileID: 4536071255097187218}
- component: {fileID: 5835331043321630532}
m_Layer: 5
m_Name: new
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1145193307346210204
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6847515371386411778}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8079540942653106974}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 21.9, y: 21.3}
m_SizeDelta: {x: 15.8354, y: 15.8355}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4536071255097187218
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6847515371386411778}
m_CullTransparentMesh: 1
--- !u!114 &5835331043321630532
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6847515371386411778}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: bef5646fb83a6a54f9b2720dc36259f3, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &6924915827096337323
GameObject:
m_ObjectHideFlags: 0
@@ -7,6 +7,7 @@ using System.Collections.Generic;
using UnityEngine.Audio;
using Bansonic;
using Steamworks;
using GameServer.Client;
public class btmandtopController : MonoBehaviour, ICancelHandler
{
@@ -67,6 +68,9 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
public GameObject notice_prefab;
public GameObject userBag_prefab;
[Header("mail red pot")]
public Image mailRedPot;
[Header("New Back Buttons")]
[SerializeField] private Button back_navButton;
[SerializeField] private Button home_navButton;
@@ -204,6 +208,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
button_Music.onClick.AddListener(ToggleMusicPicLocal);
UpdateSteamUserInfo();
InitializeMailRedPot();
var binder = BgmUiBinder.Instance != null ? BgmUiBinder.Instance : Object.FindAnyObjectByType<BgmUiBinder>();
if (binder != null && musicPicRoot != null)
@@ -517,6 +522,11 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
}
PlayerRksService.OnRksChanged -= HandleRksChanged;
UI_Panel_Mail.OnUnreadStateChanged -= HandleMailUnreadStateChanged;
if (MailHttpService.Instance != null)
{
MailHttpService.Instance.OnMailListChanged -= HandleMailListChanged;
}
if (ReferenceEquals(activeInstance, this))
{
@@ -539,6 +549,65 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
UpdatePlayerRksText(rksAmount);
}
private void InitializeMailRedPot()
{
if (mailRedPot == null)
{
return;
}
bool useServerMail = false;
if (email_prefab != null)
{
UI_Panel_Mail mailPanel = email_prefab.GetComponent<UI_Panel_Mail>();
if (mailPanel != null)
{
useServerMail = mailPanel.UsesServerMail;
}
}
if (useServerMail && MailHttpService.Instance != null)
{
MailHttpService.Instance.SetServerModeEnabled(true);
MailHttpService.Instance.OnMailListChanged -= HandleMailListChanged;
MailHttpService.Instance.OnMailListChanged += HandleMailListChanged;
}
UI_Panel_Mail.OnUnreadStateChanged -= HandleMailUnreadStateChanged;
UI_Panel_Mail.OnUnreadStateChanged += HandleMailUnreadStateChanged;
UpdateMailRedPot();
}
private void HandleMailUnreadStateChanged()
{
UpdateMailRedPot();
}
private void HandleMailListChanged(IReadOnlyList<MailApiEntry> _)
{
UpdateMailRedPot();
}
private void UpdateMailRedPot()
{
if (mailRedPot == null)
{
return;
}
bool useServerMail = false;
if (email_prefab != null)
{
UI_Panel_Mail mailPanel = email_prefab.GetComponent<UI_Panel_Mail>();
if (mailPanel != null)
{
useServerMail = mailPanel.UsesServerMail;
}
}
mailRedPot.enabled = UI_Panel_Mail.HasUnreadMails(useServerMail);
}
private void UpdatePlayerCoinsLegacyText(int coinAmount)
{
if (playerCoins_legacy != null)
@@ -0,0 +1,214 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
[ExecuteAlways]
[DisallowMultipleComponent]
[RequireComponent(typeof(RectTransform))]
public sealed class RectChildrenHeightFitter : MonoBehaviour
{
public bool includeInactiveChildren;
public float extraTopPadding;
public float extraBottomPadding;
public bool syncLayoutElement = true;
public bool preserveDirectChildrenTopLeft = true;
private RectTransform rectTransform;
private LayoutElement layoutElement;
private float lastAppliedHeight = -1f;
private readonly Dictionary<int, ChildOffsets> childOffsets = new Dictionary<int, ChildOffsets>();
private struct ChildOffsets
{
public float LeftOffset;
public float TopOffset;
}
private void Awake()
{
CacheComponents();
Refresh();
}
private void OnEnable()
{
CacheComponents();
Refresh();
}
private void OnValidate()
{
CacheComponents();
Refresh();
}
private void LateUpdate()
{
Refresh();
}
private void CacheComponents()
{
if (rectTransform == null)
{
rectTransform = GetComponent<RectTransform>();
}
if (syncLayoutElement && layoutElement == null)
{
layoutElement = GetComponent<LayoutElement>();
}
}
private void Refresh()
{
if (rectTransform == null)
{
return;
}
CacheChildOffsetsIfNeeded();
var hasBounds = false;
var minY = float.PositiveInfinity;
var maxY = float.NegativeInfinity;
var corners = new Vector3[4];
for (var i = 0; i < rectTransform.childCount; i++)
{
if (!(rectTransform.GetChild(i) is RectTransform child))
{
continue;
}
if (!includeInactiveChildren && !child.gameObject.activeSelf)
{
continue;
}
child.GetWorldCorners(corners);
for (var c = 0; c < 4; c++)
{
var localPoint = rectTransform.InverseTransformPoint(corners[c]);
minY = Mathf.Min(minY, localPoint.y);
maxY = Mathf.Max(maxY, localPoint.y);
hasBounds = true;
}
}
var targetHeight = hasBounds
? Mathf.Max(0f, (maxY - minY) + extraTopPadding + extraBottomPadding)
: 0f;
if (!Mathf.Approximately(lastAppliedHeight, targetHeight))
{
rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, targetHeight);
RestoreDirectChildPositions();
if (syncLayoutElement)
{
if (layoutElement == null)
{
layoutElement = GetComponent<LayoutElement>();
}
if (layoutElement != null)
{
layoutElement.minHeight = -1f;
layoutElement.preferredHeight = targetHeight;
layoutElement.flexibleHeight = -1f;
}
}
LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
if (rectTransform.parent is RectTransform parentRect)
{
LayoutRebuilder.MarkLayoutForRebuild(parentRect);
}
lastAppliedHeight = targetHeight;
}
}
private void CacheChildOffsetsIfNeeded()
{
if (!preserveDirectChildrenTopLeft || rectTransform == null)
{
return;
}
if (childOffsets.Count == rectTransform.childCount)
{
var allPresent = true;
for (var i = 0; i < rectTransform.childCount; i++)
{
if (!childOffsets.ContainsKey(rectTransform.GetChild(i).GetInstanceID()))
{
allPresent = false;
break;
}
}
if (allPresent)
{
return;
}
}
childOffsets.Clear();
var parentRect = rectTransform.rect;
for (var i = 0; i < rectTransform.childCount; i++)
{
if (!(rectTransform.GetChild(i) is RectTransform child))
{
continue;
}
var localPivotPosition = (Vector2)child.localPosition;
childOffsets[child.GetInstanceID()] = new ChildOffsets
{
LeftOffset = localPivotPosition.x - parentRect.xMin,
TopOffset = parentRect.yMax - localPivotPosition.y
};
}
}
private void RestoreDirectChildPositions()
{
if (!preserveDirectChildrenTopLeft || rectTransform == null)
{
return;
}
var parentRect = rectTransform.rect;
for (var i = 0; i < rectTransform.childCount; i++)
{
if (!(rectTransform.GetChild(i) is RectTransform child))
{
continue;
}
if (!childOffsets.TryGetValue(child.GetInstanceID(), out var offsets))
{
continue;
}
// Only handle fixed-anchor direct children. Stretched children should keep their own layout behavior.
if (!Mathf.Approximately(child.anchorMin.x, child.anchorMax.x)
|| !Mathf.Approximately(child.anchorMin.y, child.anchorMax.y))
{
continue;
}
var desiredLocalPivot = new Vector2(
parentRect.xMin + offsets.LeftOffset,
parentRect.yMax - offsets.TopOffset);
var anchorReference = new Vector2(
Mathf.Lerp(parentRect.xMin, parentRect.xMax, child.anchorMin.x),
Mathf.Lerp(parentRect.yMin, parentRect.yMax, child.anchorMin.y));
child.anchoredPosition = desiredLocalPivot - anchorReference;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 232307e6a44c4ca0bfe2e260dba56267
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -13,7 +13,6 @@ public class UI_UnimplementedFeatureBlocker : MonoBehaviour
"Button_STORY",
"Button_IDOL",
"Button_NOTEBOOK",
"launchEzGame",
"Button_CHARACTER_SET",
"Button_Market",
"Button_Personal_information",
+111 -159
View File
@@ -6,6 +6,8 @@ using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Text.RegularExpressions;
using UnityEngine.Networking;
using GameServer.Client;
using Debug = UnityEngine.Debug;
@@ -19,7 +21,7 @@ public class WebViewLauncher : MonoBehaviour
public Vector2 windowPosition = new Vector2(100, 100);
[Header("Editor Only Path")]
public string editorExeRoot = @"E:\Unity\ban_total\fdBrowser";
public string editorExeRoot = @"E:\Unity\ban_total\fdGamer\build\windows\x64\runner\Release";
[Header("H5 Folder Paths")]
public string h5EditorPath = @"E:\Unity\ban_total\ban_test\Bansonic_Data\StreamingAssets\h5LG";
@@ -28,6 +30,8 @@ public class WebViewLauncher : MonoBehaviour
public string thirdPartyGamesPath = "_thirdPartyGames";
private Process webProcess;
private const string FlutterExeName = "浮动小游戏.exe";
private const string LocalControlBaseUrl = "http://127.0.0.1:18961";
// Event invoked when web process main window handle becomes available
public event Action WebViewReady;
@@ -87,7 +91,7 @@ public class WebViewLauncher : MonoBehaviour
if (goButton != null) goButton.onClick.AddListener(OnGoButtonClicked);
// Load autostart preference and bind toggle
autostart = PlayerPrefs.GetInt(PREF_AUTOSTART, 1) == 1;
autostart = PlayerPrefs.GetInt(PREF_AUTOSTART, 0) == 1;
if (autostartToggle != null)
{
autostartToggle.isOn = autostart;
@@ -97,72 +101,19 @@ public class WebViewLauncher : MonoBehaviour
// set default homepage if empty
if (string.IsNullOrEmpty(homepageUrl))
{
#if UNITY_EDITOR
string candidate = Path.Combine(h5EditorPath, "_officialDocs", "openings", "index.html");
if (File.Exists(candidate))
homepageUrl = new Uri(candidate).AbsoluteUri;
else
homepageUrl = startUrl;
#else
string candidate = Path.Combine(Application.streamingAssetsPath, "h5LG", "_officialDocs", "openings", "index.html");
if (File.Exists(candidate))
homepageUrl = new Uri(candidate).AbsoluteUri;
else
homepageUrl = startUrl;
#endif
homepageUrl = string.Empty;
}
}
void Start()
{
// Ensure H5 root exists
string h5Folder = GetH5FolderPath();
if (!Directory.Exists(h5Folder))
{
Directory.CreateDirectory(h5Folder);
Debug.Log("Created H5 folder: " + h5Folder);
}
// Ensure controlText is visible by default
if (controlText != null)
{
controlText.gameObject.SetActive(true);
Debug.Log("Control text set to visible by default");
}
// Prefer explicit openings index as startup page when available
string preferred = Path.Combine(h5Folder, "_officialDocs", "openings", "index.html");
if (File.Exists(preferred))
{
startUrl = new Uri(preferred).AbsoluteUri;
Debug.Log("Using preferred startup page: " + startUrl);
// show initial url in input field
if (urlInputField != null)
urlInputField.text = GetDisplayUrl(startUrl);
if (autostart) LaunchWebView();
return;
}
// Documentation text normalized.
var h5SubFolders = ScanH5Folders(h5Folder);
if (h5SubFolders.Count > 0)
{
Debug.Log("Found H5 folders: " + string.Join(", ", h5SubFolders));
string selectedFolder = h5SubFolders[0]; // Documentation text normalized.
string candidatePath = Path.Combine(h5Folder, selectedFolder, "index.html");
startUrl = new Uri(candidatePath).AbsoluteUri; // ensure proper file:/// URI
Debug.Log("Selected H5 folder: " + selectedFolder + ", URL: " + startUrl);
}
else
{
Debug.LogWarning("No H5 subfolders with index.html found in: " + h5Folder);
}
// show initial url in input field if available (use shortened display for local files that are indexed)
if (urlInputField != null)
{
urlInputField.text = GetDisplayUrl(startUrl);
urlInputField.text = string.Empty;
}
if (autostart) LaunchWebView();
@@ -245,7 +196,65 @@ public class WebViewLauncher : MonoBehaviour
}
}
string GetServerBaseUrl()
{
if (NetworkManager.Instance != null && !string.IsNullOrWhiteSpace(NetworkManager.Instance.ServerUrl))
{
string raw = NetworkManager.Instance.ServerUrl.Trim();
if (Uri.TryCreate(raw, UriKind.Absolute, out Uri parsed))
{
return $"{parsed.Scheme}://{parsed.Authority}";
}
return raw.TrimEnd('/');
}
return "http://47.112.187.172:8080";
}
string BuildFlutterLaunchArguments(string openUrl)
{
string args = $"--server-base=\"{GetServerBaseUrl()}\"";
if (!string.IsNullOrWhiteSpace(openUrl))
{
args += $" --open-url=\"{openUrl}\"";
}
return args;
}
IEnumerator SendLocalControlRequest(string path, string method = UnityWebRequest.kHttpVerbGET, string jsonBody = null)
{
string url = $"{LocalControlBaseUrl}{path}";
using UnityWebRequest request = new UnityWebRequest(url, method);
request.downloadHandler = new DownloadHandlerBuffer();
if (!string.IsNullOrEmpty(jsonBody))
{
byte[] bodyRaw = System.Text.Encoding.UTF8.GetBytes(jsonBody);
request.uploadHandler = new UploadHandlerRaw(bodyRaw);
request.SetRequestHeader("Content-Type", "application/json");
}
yield return request.SendWebRequest();
if (request.result != UnityWebRequest.Result.Success)
{
Debug.LogWarning($"Local Flutter control request failed: {method} {url} -> {request.error}");
}
}
void SendLocalControlOpen(string normalizedUrl)
{
string escaped = normalizedUrl.Replace("\\", "\\\\").Replace("\"", "\\\"");
StartCoroutine(SendLocalControlRequest("/open", UnityWebRequest.kHttpVerbPOST, $"{{\"url\":\"{escaped}\"}}"));
}
void SendLocalControlCommand(string path)
{
StartCoroutine(SendLocalControlRequest(path));
}
void LaunchWebView()
{
LaunchWebViewWithUrl(string.Empty);
}
void LaunchWebViewWithUrlInternal(string openUrl)
{
string exePath = GetExePath();
@@ -253,12 +262,11 @@ public class WebViewLauncher : MonoBehaviour
if (!File.Exists(exePath))
{
Debug.LogError("fdBrowser.exe not found: " + exePath);
Debug.LogError("浮动小游戏主程序不存在: " + exePath);
return;
}
// Documentation text normalized.
string args = $"0 0 800 600 \"{startUrl}\"";
string args = BuildFlutterLaunchArguments(openUrl);
Debug.Log($"Launching: {exePath} {args}");
@@ -273,7 +281,7 @@ public class WebViewLauncher : MonoBehaviour
try
{
webProcess = Process.Start(psi);
Debug.Log("WebView2Host started successfully. Process ID: " + webProcess.Id);
Debug.Log("浮动小游戏已启动。PID: " + webProcess.Id);
// Start coroutine to wait until main window handle is ready
StartCoroutine(WaitForMainWindowHandle());
@@ -373,64 +381,49 @@ public class WebViewLauncher : MonoBehaviour
if (urlInputField != null)
urlInputField.text = GetDisplayUrl(final);
// if process not running, launch; otherwise try to send url to existing window
if (webProcess == null || webProcess.HasExited)
{
Debug.Log("WebView process not running. Launching with URL: " + final);
LaunchWebView();
Debug.Log("浮动小游戏未运行,直接启动并打开 URL: " + final);
LaunchWebViewWithUrlInternal(final);
return;
}
try
{
Debug.Log($"WebView process running. PID={webProcess.Id}, MainWindowHandle=0x{webProcess.MainWindowHandle.ToInt64():X}");
}
catch { }
// Documentation text normalized.
bool sent = WebViewWin32.TrySendUrlToWindow(webProcess, final);
Debug.Log($"TrySendUrlToWindow returned: {sent}");
if (sent)
{
Debug.Log("Sent URL to existing WebView process: " + final);
// Notify followers that webview content may have changed and they should reapply positioning
WebViewReady?.Invoke();
return;
}
// Documentation text normalized.
Debug.Log("Failed to send URL to existing process, restarting to open: " + final);
KillWebView();
LaunchWebView();
// after relaunch, WaitForMainWindowHandle will invoke WebViewReady when handle ready
SendLocalControlOpen(final);
WebViewReady?.Invoke();
}
// Try to send a simple command string to the webview process via WM_COPYDATA. Returns true when SendMessage returned non-zero.
bool TrySendCommand(string cmd)
{
if (webProcess == null || webProcess.HasExited)
{
Debug.LogWarning("TrySendCommand: webProcess not running");
Debug.LogWarning("TrySendCommand: 浮动小游戏未运行");
return false;
}
bool sent = WebViewWin32.TrySendUrlToWindow(webProcess, cmd);
Debug.Log($"TrySendCommand('{cmd}') returned: {sent}");
return sent;
switch (cmd)
{
case "CMD:REFRESH":
SendLocalControlCommand("/refresh");
return true;
case "CMD:BACK":
SendLocalControlCommand("/back");
return true;
case "CMD:FORWARD":
SendLocalControlCommand("/forward");
return true;
case "CMD:HOME":
SendLocalControlCommand("/home");
return true;
default:
return false;
}
}
// UI control methods
public void RefreshWebView()
{
// Try sending a refresh command; fallback to restarting to refresh
if (TrySendCommand("CMD:REFRESH"))
{
Debug.Log("Sent REFRESH command to webview");
return;
}
Debug.Log("REFRESH command not supported, restarting webview to refresh");
KillWebView();
LaunchWebView();
}
@@ -442,7 +435,6 @@ public class WebViewLauncher : MonoBehaviour
public void RestartWebView()
{
Debug.Log("Restarting webview process");
KillWebView();
LaunchWebView();
}
@@ -469,28 +461,7 @@ public class WebViewLauncher : MonoBehaviour
void OnHomepageClicked()
{
// Always navigate to StreamingAssets/h5LG/_officialDocs/openings/index.html
string candidate = Path.Combine(Application.streamingAssetsPath, "h5LG", "_officialDocs", "openings", "index.html");
if (!File.Exists(candidate))
{
Debug.LogWarning("Homepage index not found at: " + candidate + ". Falling back to homepageUrl or startUrl.");
if (!string.IsNullOrEmpty(homepageUrl))
{
LaunchWebViewWithUrl(homepageUrl);
}
else
{
LaunchWebViewWithUrl(startUrl);
}
return;
}
string fileUri = new Uri(candidate).AbsoluteUri;
LaunchWebViewWithUrl(fileUri);
// OpenUrl will update the input field using GetDisplayUrl(final). Ensure display shows the shortened localhost form.
if (urlInputField != null)
urlInputField.text = GetDisplayUrl(fileUri);
StartWebView();
}
void OnUrlInputEndEdit(string text)
@@ -559,7 +530,13 @@ public class WebViewLauncher : MonoBehaviour
public void StartWebView()
{
LaunchWebView();
if (webProcess == null || webProcess.HasExited)
{
LaunchWebView();
return;
}
SendLocalControlCommand("/home");
WebViewReady?.Invoke();
}
public void StopWebView()
@@ -578,19 +555,20 @@ public class WebViewLauncher : MonoBehaviour
string GetExePath()
{
#if UNITY_EDITOR
return Path.Combine(editorExeRoot, "fdBrowser.exe");
string editorPath = Path.Combine(editorExeRoot, FlutterExeName);
if (File.Exists(editorPath))
{
return editorPath;
}
return Path.Combine(Application.streamingAssetsPath, "fdGamer", FlutterExeName);
#else
// Documentation text normalized.
string streamingPath = Path.Combine(Application.streamingAssetsPath, "fdBrowser", "fdBrowser.exe");
string streamingPath = Path.Combine(Application.streamingAssetsPath, "fdGamer", FlutterExeName);
if (File.Exists(streamingPath))
{
Debug.Log("Using StreamingAssets path: " + streamingPath);
return streamingPath;
}
// Documentation text normalized.
string gameRoot = Path.GetDirectoryName(Application.dataPath);
string fallbackPath = Path.Combine(gameRoot, "fdBrowser", "fdBrowser.exe");
Debug.Log("Using fallback path: " + fallbackPath);
string fallbackPath = Path.Combine(gameRoot, "fdGamer", FlutterExeName);
return fallbackPath;
#endif
}
@@ -646,10 +624,7 @@ public class WebViewLauncher : MonoBehaviour
/// </summary>
public bool TryUpdateWebViewRect(int x, int y, int w, int h)
{
if (webProcess == null || webProcess.HasExited)
return false;
return WebViewWin32.TrySetWindowRect(webProcess, x, y, w, h);
return webProcess != null && !webProcess.HasExited;
}
string GetDisplayUrl(string url)
@@ -729,35 +704,12 @@ public class WebViewLauncher : MonoBehaviour
if (urlInputField != null)
urlInputField.text = GetDisplayUrl(finalUrl);
// if process not running, launch; otherwise try to send url to existing window
if (webProcess == null || webProcess.HasExited)
{
Debug.Log("WebView process not running. Launching with URL: " + finalUrl);
LaunchWebView();
LaunchWebViewWithUrlInternal(finalUrl);
return;
}
try
{
Debug.Log($"WebView process running. PID={webProcess.Id}, MainWindowHandle=0x{webProcess.MainWindowHandle.ToInt64():X}");
}
catch { }
// Documentation text normalized.
bool sent = WebViewWin32.TrySendUrlToWindow(webProcess, finalUrl);
Debug.Log($"TrySendUrlToWindow returned: {sent}");
if (sent)
{
Debug.Log("Sent URL to existing WebView process: " + finalUrl);
// Notify followers that webview content may have changed and they should reapply positioning
WebViewReady?.Invoke();
return;
}
// Documentation text normalized.
Debug.Log("Failed to send URL to existing process, restarting to open: " + finalUrl);
KillWebView();
LaunchWebView();
// after relaunch, WaitForMainWindowHandle will invoke WebViewReady when handle ready
SendLocalControlOpen(finalUrl);
WebViewReady?.Invoke();
}
}
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
public sealed class ExpBottleLedger : MonoBehaviour
@@ -219,8 +218,6 @@ public sealed class ExpBottleLedger : MonoBehaviour
InitializeIfNeeded();
bool changed = false;
var flags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
var type = typeof(Player_SO);
for (int i = 0; i < ExpBottleCatalog.All.Count; i++)
{
@@ -229,14 +226,7 @@ public sealed class ExpBottleLedger : MonoBehaviour
{
continue;
}
var field = type.GetField(descriptor.LegacyPlayerFieldName, flags);
if (field == null || field.FieldType != typeof(int))
{
continue;
}
var legacyValue = Mathf.Max(0, (int)field.GetValue(playerData));
var legacyValue = Mathf.Max(0, playerData.GetLegacyExpBottleCount(descriptor.LegacyPlayerFieldName));
var currentValue = GetCountByKey(descriptor.Key);
if (!overwriteExistingCounts && currentValue > 0)
{
@@ -44,6 +44,7 @@ public sealed class PlayerEconomyLedger : MonoBehaviour
Instance = this;
DontDestroyOnLoad(gameObject);
InitializeIfNeeded();
TryAttachDefaultPlayerData();
}
private void OnApplicationPause(bool pauseStatus)
@@ -87,6 +88,15 @@ public sealed class PlayerEconomyLedger : MonoBehaviour
InitializeIfNeeded();
boundPlayerData = playerData;
if (!loadedFromSave)
{
payload.coins = Mathf.Max(0, playerData.Coins);
payload.material = Mathf.Max(0, playerData.Material);
SaveNow();
loadedFromSave = true;
return;
}
SyncToPlayerData();
GlobalAchievementService.EnsureInstance().ReportCurrentCoins(payload.coins);
NotifyEconomyChanged();
@@ -257,4 +267,14 @@ public sealed class PlayerEconomyLedger : MonoBehaviour
OnMaterialChanged(payload.material);
}
}
private void TryAttachDefaultPlayerData()
{
Player_SO player = RuntimeResourcesCache.LoadDefaultPlayerSo();
if (player != null)
{
AttachPlayerData(player);
}
}
}
@@ -85,7 +85,7 @@ public static class PlayerEconomyStorage
{
version = 1,
lastUpdatedUtcTicks = DateTime.UtcNow.Ticks,
coins = 999999,
coins = 0,
material = 0
};
}
@@ -0,0 +1,218 @@
using System;
using System.IO;
using UnityEngine;
public sealed class PlayerExperienceLedger : MonoBehaviour
{
[Serializable]
private class PlayerExperiencePayload
{
public int version = 1;
public long lastUpdatedUtcTicks;
public int playerExp;
}
public static PlayerExperienceLedger Instance { get; private set; }
public event Action<int> OnExperienceChanged;
private PlayerExperiencePayload payload;
private bool initialized;
private bool loadedFromSave;
private Player_SO boundPlayerData;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void Bootstrap()
{
EnsureInstance();
}
public static PlayerExperienceLedger EnsureInstance()
{
if (Instance != null)
{
return Instance;
}
var host = new GameObject("__runtime_player_exp_bridge");
host.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector;
DontDestroyOnLoad(host);
Instance = host.AddComponent<PlayerExperienceLedger>();
return Instance;
}
private void Awake()
{
if (Instance != null && Instance != this)
{
Destroy(gameObject);
return;
}
Instance = this;
DontDestroyOnLoad(gameObject);
InitializeIfNeeded();
TryAttachDefaultPlayerData();
}
private void OnApplicationPause(bool pauseStatus)
{
if (pauseStatus)
{
SaveNow();
}
}
private void OnApplicationQuit()
{
SaveNow();
}
public void InitializeIfNeeded()
{
if (initialized)
{
return;
}
loadedFromSave = SecureSaveVault.TryLoadJson("player_experience", "runtime", out payload, GetLegacySavePath());
if (payload == null)
{
payload = CreateDefaultPayload();
}
initialized = true;
}
public void AttachPlayerData(Player_SO playerData)
{
if (playerData == null)
{
return;
}
InitializeIfNeeded();
boundPlayerData = playerData;
if (!loadedFromSave)
{
payload.playerExp = Mathf.Max(0, playerData.player_currentEXP);
SaveNow();
loadedFromSave = true;
return;
}
SyncToPlayerData();
NotifyExperienceChanged();
}
public int GetExperience()
{
InitializeIfNeeded();
return payload.playerExp;
}
public void AddExperience(int amount)
{
if (amount == 0)
{
return;
}
InitializeIfNeeded();
long next = (long)payload.playerExp + amount;
if (next < 0)
{
next = 0;
}
else if (next > int.MaxValue)
{
next = int.MaxValue;
}
payload.playerExp = (int)next;
SaveNow();
}
public bool TryConsumeExperience(int amount)
{
if (amount <= 0)
{
return true;
}
InitializeIfNeeded();
if (payload.playerExp < amount)
{
return false;
}
payload.playerExp -= amount;
SaveNow();
return true;
}
public void SaveNow()
{
if (!initialized)
{
InitializeIfNeeded();
}
if (payload == null)
{
payload = CreateDefaultPayload();
}
payload.lastUpdatedUtcTicks = DateTime.UtcNow.Ticks;
SecureSaveVault.SaveJson("player_experience", "runtime", payload, GetLegacySavePath());
SyncToPlayerData();
NotifyExperienceChanged();
}
private void SyncToPlayerData()
{
if (boundPlayerData == null || payload == null)
{
return;
}
boundPlayerData.player_currentEXP = Mathf.Max(0, payload.playerExp);
#if UNITY_EDITOR
if (!Application.isPlaying)
{
UnityEditor.EditorUtility.SetDirty(boundPlayerData);
}
#endif
}
private void NotifyExperienceChanged()
{
OnExperienceChanged?.Invoke(GetExperience());
}
private void TryAttachDefaultPlayerData()
{
Player_SO player = RuntimeResourcesCache.LoadDefaultPlayerSo();
if (player != null)
{
AttachPlayerData(player);
}
}
private static PlayerExperiencePayload CreateDefaultPayload()
{
return new PlayerExperiencePayload
{
version = 1,
lastUpdatedUtcTicks = DateTime.UtcNow.Ticks,
playerExp = 0,
};
}
private static string GetLegacySavePath()
{
return Path.Combine(Application.persistentDataPath, "player_experience.json");
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ea76e6465f93823418420efa7c62c0f0
@@ -97,7 +97,7 @@ public static class PlayerRksService
private static Player_SO LoadDefaultPlayerSo()
{
Player_SO[] players = Resources.LoadAll<Player_SO>(string.Empty);
Player_SO[] players = RuntimeResourcesCache.LoadAll<Player_SO>(string.Empty);
if (players == null)
{
return null;
@@ -116,7 +116,7 @@ public static class PlayerRksService
private static float CalculateOverallRksRaw()
{
SongData[] songs = Resources.LoadAll<SongData>(string.Empty);
SongData[] songs = RuntimeResourcesCache.LoadAllSongs();
if (songs == null || songs.Length == 0)
{
return 0f;
@@ -171,7 +171,7 @@ public static class PlayerRksService
private static float GetMaxChartConstant()
{
SongData[] songs = Resources.LoadAll<SongData>(string.Empty);
SongData[] songs = RuntimeResourcesCache.LoadAllSongs();
float maxConstant = 0f;
if (songs == null)
{
@@ -491,6 +491,35 @@ public sealed class PlayerSkillService : MonoBehaviour
return;
}
bool assetChanged = false;
if (saveData.selectedSkillIndex >= 0 && saveData.selectedSkillIndex < registeredSkillAsset.skills.Count)
{
for (int i = 0; i < registeredSkillAsset.skills.Count; i++)
{
userLevel_skills_SO.UserLevelSkillEntry entry = registeredSkillAsset.skills[i];
if (entry == null)
{
continue;
}
bool shouldEnable = i == saveData.selectedSkillIndex;
if (entry.isEnabled != shouldEnable)
{
entry.isEnabled = shouldEnable;
assetChanged = true;
}
}
#if UNITY_EDITOR
if (assetChanged && !Application.isPlaying)
{
UnityEditor.EditorUtility.SetDirty(registeredSkillAsset);
}
#endif
return;
}
int enabledIndex = -1;
for (int i = 0; i < registeredSkillAsset.skills.Count; i++)
{
@@ -595,7 +624,7 @@ public sealed class PlayerSkillService : MonoBehaviour
return cachedRandomMemoryRewardItem;
}
storeItemSO[] items = Resources.LoadAll<storeItemSO>("so/storeSO");
storeItemSO[] items = RuntimeResourcesCache.LoadAllStoreItems();
for (int i = 0; i < items.Length; i++)
{
if (items[i] != null && items[i].itemID == RandomMemoryStoreItemId)
@@ -611,7 +640,7 @@ public sealed class PlayerSkillService : MonoBehaviour
private int GetOwnedHeroCount()
{
HashSet<int> heroIds = new HashSet<int>();
AllyHero_SO[] heroes = Resources.LoadAll<AllyHero_SO>(string.Empty);
AllyHero_SO[] heroes = RuntimeResourcesCache.LoadAllAllyHeroes();
if (heroes == null)
{
return 0;

Some files were not shown because too many files have changed in this diff Show More