功能批量实现 优化 服务端 新浮动小游戏框架 新界面UI
This commit is contained in:
@@ -7,6 +7,7 @@ using System.IO;
|
||||
|
||||
public class dlcButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
private const bool VerboseLogs = false;
|
||||
[Header("Inspector")]
|
||||
public Image dlc_profileImgae;
|
||||
public Text dlcName;
|
||||
@@ -118,7 +119,7 @@ public class dlcButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandle
|
||||
dlc_nowSelectedImageBoarder.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
Debug.Log($"dlcButton.Awake: registered '{gameObject.name}' as index {instanceIndex}");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton.Awake: registered '{gameObject.name}' as index {instanceIndex}");
|
||||
}
|
||||
|
||||
private void RegisterInstance()
|
||||
@@ -175,7 +176,7 @@ public class dlcButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandle
|
||||
selectedIndex = instanceIndex;
|
||||
PlayerPrefs.SetInt(PlayerPrefsKey, selectedIndex);
|
||||
PlayerPrefs.Save();
|
||||
Debug.Log($"dlcButton.Select: '{gameObject.name}' selected (index {instanceIndex}) and saved to PlayerPrefs");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton.Select: '{gameObject.name}' selected (index {instanceIndex}) and saved to PlayerPrefs");
|
||||
}
|
||||
|
||||
private static void ApplySelectionToAll(int selectIdx)
|
||||
@@ -330,7 +331,7 @@ public class dlcButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandle
|
||||
// Try to find a dlcData SO by id and apply its songList to dlcContent
|
||||
public void LoadDlcDataById(int id)
|
||||
{
|
||||
Debug.Log($"dlcButton.LoadDlcDataById: searching for id={id} (editorFolder='{editorSearchFolder}', runtimeFolder='{runtimeResourcesFolder}') on '{gameObject.name}'");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton.LoadDlcDataById: searching for id={id} (editorFolder='{editorSearchFolder}', runtimeFolder='{runtimeResourcesFolder}') on '{gameObject.name}'");
|
||||
#if UNITY_EDITOR
|
||||
// Editor search: search recursively for asset files under editorSearchFolder
|
||||
if (!string.IsNullOrEmpty(editorSearchFolder) && Directory.Exists(editorSearchFolder))
|
||||
@@ -338,18 +339,18 @@ public class dlcButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandle
|
||||
try
|
||||
{
|
||||
var files = Directory.GetFiles(editorSearchFolder, "*.asset", SearchOption.AllDirectories);
|
||||
Debug.Log($"dlcButton.LoadDlcDataById: found {files.Length} asset files under {editorSearchFolder}");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton.LoadDlcDataById: found {files.Length} asset files under {editorSearchFolder}");
|
||||
foreach (var path in files)
|
||||
{
|
||||
string fileName = Path.GetFileNameWithoutExtension(path);
|
||||
if (fileName.StartsWith(id.ToString()))
|
||||
{
|
||||
string assetPath = path.Replace("\\", "/");
|
||||
Debug.Log($"dlcButton.LoadDlcDataById: candidate assetPath={assetPath}");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton.LoadDlcDataById: candidate assetPath={assetPath}");
|
||||
var so = UnityEditor.AssetDatabase.LoadAssetAtPath<dlcData>(assetPath);
|
||||
if (so != null)
|
||||
{
|
||||
Debug.Log($"dlcButton.LoadDlcDataById: loaded dlcData SO '{so.name}' for id={id}");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton.LoadDlcDataById: loaded dlcData SO '{so.name}' for id={id}");
|
||||
dlcDataSO = so;
|
||||
ApplyDlcData(so);
|
||||
return;
|
||||
@@ -364,14 +365,14 @@ public class dlcButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandle
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"dlcButton.LoadDlcDataById: editorSearchFolder '{editorSearchFolder}' does not exist or not set");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton.LoadDlcDataById: editorSearchFolder '{editorSearchFolder}' does not exist or not set");
|
||||
}
|
||||
#endif
|
||||
// Runtime: search Resources (load all dlcData then filter by name prefix)
|
||||
try
|
||||
{
|
||||
var arr = Resources.LoadAll<dlcData>(runtimeResourcesFolder);
|
||||
Debug.Log($"dlcButton.LoadDlcDataById: Resources.LoadAll('{runtimeResourcesFolder}') returned {(arr != null ? arr.Length : 0)} items");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton.LoadDlcDataById: Resources.LoadAll('{runtimeResourcesFolder}') returned {(arr != null ? arr.Length : 0)} items");
|
||||
if (arr != null)
|
||||
{
|
||||
foreach (var so in arr)
|
||||
@@ -379,7 +380,7 @@ public class dlcButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandle
|
||||
if (so == null) continue;
|
||||
if (so.name.StartsWith(id.ToString()))
|
||||
{
|
||||
Debug.Log($"dlcButton.LoadDlcDataById: found runtime dlcData '{so.name}' for id={id}");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton.LoadDlcDataById: found runtime dlcData '{so.name}' for id={id}");
|
||||
dlcDataSO = so;
|
||||
ApplyDlcData(so);
|
||||
return;
|
||||
@@ -394,7 +395,7 @@ public class dlcButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandle
|
||||
|
||||
// fallback: search all Resources
|
||||
var all = Resources.LoadAll<dlcData>("");
|
||||
Debug.Log("dlcButton.LoadDlcDataById: Resources.LoadAll(\"\") returned " + (all != null ? all.Length : 0) + " items");
|
||||
if (VerboseLogs) Debug.Log("dlcButton.LoadDlcDataById: Resources.LoadAll(\"\") returned " + (all != null ? all.Length : 0) + " items");
|
||||
if (all != null)
|
||||
{
|
||||
foreach (var so in all)
|
||||
@@ -402,7 +403,7 @@ public class dlcButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandle
|
||||
if (so == null) continue;
|
||||
if (so.name.StartsWith(id.ToString()))
|
||||
{
|
||||
Debug.Log($"dlcButton.LoadDlcDataById: found fallback dlcData '{so.name}' for id={id}");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton.LoadDlcDataById: found fallback dlcData '{so.name}' for id={id}");
|
||||
dlcDataSO = so;
|
||||
ApplyDlcData(so);
|
||||
return;
|
||||
@@ -411,7 +412,7 @@ public class dlcButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandle
|
||||
}
|
||||
|
||||
// if no dlcData found, keep dlcContent empty but attempt old behavior: search SongData by id prefix
|
||||
Debug.Log($"dlcButton.LoadDlcDataById: no dlcData found for id={id}, falling back to song prefix search");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton.LoadDlcDataById: no dlcData found for id={id}, falling back to song prefix search");
|
||||
LoadContentBySongIdPrefix(id);
|
||||
}
|
||||
|
||||
@@ -441,7 +442,7 @@ public class dlcButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandle
|
||||
dlc_profileImgae.enabled = so.dlc_image != null;
|
||||
}
|
||||
|
||||
Debug.Log($"dlcButton.ApplyDlcData: applied dlcData '{so.name}' with {dlcContent.Count} songs to button '{gameObject.name}'");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton.ApplyDlcData: applied dlcData '{so.name}' with {dlcContent.Count} songs to button '{gameObject.name}'");
|
||||
}
|
||||
|
||||
// Legacy: if no dlcData SO, search SongData assets by id prefix and fill dlcContent
|
||||
@@ -497,7 +498,7 @@ public class dlcButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandle
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"dlcButton: Loaded {dlcContent.Count} SongData entries for DLC id={id} (fallback search)");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton: Loaded {dlcContent.Count} SongData entries for DLC id={id} (fallback search)");
|
||||
}
|
||||
|
||||
// Resolve dlcData after all buttons have been instantiated
|
||||
@@ -517,11 +518,11 @@ public class dlcButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandle
|
||||
yield break;
|
||||
}
|
||||
|
||||
Debug.Log($"dlcButton.ResolveDlcData called on '{gameObject.name}'");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton.ResolveDlcData called on '{gameObject.name}'");
|
||||
|
||||
if (dlcDataSO != null)
|
||||
{
|
||||
Debug.Log($"dlcButton: dlcDataSO already assigned on '{gameObject.name}' -> {dlcDataSO.name}");
|
||||
if (VerboseLogs) Debug.Log($"dlcButton: dlcDataSO already assigned on '{gameObject.name}' -> {dlcDataSO.name}");
|
||||
ApplyDlcData(dlcDataSO);
|
||||
Resolved = true;
|
||||
yield break;
|
||||
|
||||
Reference in New Issue
Block a user