成就系统 巨大修改 新的ui 黑白效果 等一堆
This commit is contained in:
@@ -2457,7 +2457,7 @@ Canvas:
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 666
|
||||
m_SortingOrder: 1235
|
||||
m_TargetDisplay: 0
|
||||
--- !u!114 &5224241407313794548
|
||||
MonoBehaviour:
|
||||
@@ -2504,7 +2504,7 @@ MonoBehaviour:
|
||||
notice_display: {fileID: 920723299105391293}
|
||||
showLevel_prefab: {fileID: 775714823646948286, guid: 4c26aec0fc471c24d94487eff6821e14, type: 3}
|
||||
store_prefab: {fileID: 0}
|
||||
settings_prefab: {fileID: 0}
|
||||
settings_prefab: {fileID: 4801108313180107556, guid: 8db6dd820b152984980f7fd2124138c3, type: 3}
|
||||
userInfo_prefab: {fileID: 0}
|
||||
email_prefab: {fileID: 3756075665884320709, guid: 41f4ea31b64f18d48aeef21b79930a6c, type: 3}
|
||||
notice_prefab: {fileID: 8527835049849151044, guid: 06bb6d3a45697374ab4f5ff36356d138, type: 3}
|
||||
|
||||
@@ -31,9 +31,12 @@ public class btmandtopController : MonoBehaviour
|
||||
private UnityAction instantiateEmail;
|
||||
private UnityAction instantiateNotice;
|
||||
|
||||
// cached reference to the settings instance to ensure only one exists
|
||||
private GameObject settingsInstance;
|
||||
|
||||
void Start()
|
||||
{
|
||||
instantiateSettings = () => InstantiatePrefab(settings_prefab);
|
||||
instantiateSettings = () => ToggleSettingsPrefab();
|
||||
instantiateUserInfo = () => InstantiatePrefab(userInfo_prefab);
|
||||
instantiateStore = () => InstantiatePrefab(store_prefab);
|
||||
instantiateShowLevel = () => InstantiatePrefab(showLevel_prefab);
|
||||
@@ -52,6 +55,49 @@ public class btmandtopController : MonoBehaviour
|
||||
email_display.onClick.AddListener(instantiateEmail);
|
||||
if (notice_display != null)
|
||||
notice_display.onClick.AddListener(instantiateNotice);
|
||||
|
||||
// Pre-instantiate settings prefab and keep it inactive, ensuring only one exists
|
||||
if (settings_prefab != null && putPrefabsHere != null)
|
||||
{
|
||||
// Try to find existing one in scene first
|
||||
if (settingsInstance == null)
|
||||
{
|
||||
var existing = GameObject.Find(settings_prefab.name + "(Clone)");
|
||||
if (existing != null)
|
||||
{
|
||||
settingsInstance = existing;
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsInstance == null)
|
||||
{
|
||||
settingsInstance = Instantiate(settings_prefab, putPrefabsHere.transform);
|
||||
settingsInstance.SetActive(false);
|
||||
|
||||
// try to set canvas camera now as in previous behavior
|
||||
try
|
||||
{
|
||||
Canvas c = settingsInstance.GetComponentInChildren<Canvas>(true);
|
||||
if (c != null)
|
||||
{
|
||||
Camera[] cams = GameObject.FindObjectsOfType<Camera>();
|
||||
if (cams != null && cams.Length > 0)
|
||||
{
|
||||
c.worldCamera = cams[0];
|
||||
}
|
||||
cams = null;
|
||||
c = null;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
else
|
||||
{
|
||||
// ensure it's parented correctly under putPrefabsHere
|
||||
settingsInstance.transform.SetParent(putPrefabsHere.transform, false);
|
||||
settingsInstance.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
@@ -70,11 +116,47 @@ public class btmandtopController : MonoBehaviour
|
||||
notice_display.onClick.RemoveListener(instantiateNotice);
|
||||
}
|
||||
|
||||
private void ToggleSettingsPrefab()
|
||||
{
|
||||
if (settings_prefab == null || putPrefabsHere == null) return;
|
||||
|
||||
// If we don't have an instance (it may have been destroyed), instantiate one
|
||||
if (settingsInstance == null)
|
||||
{
|
||||
settingsInstance = Instantiate(settings_prefab, putPrefabsHere.transform);
|
||||
|
||||
// attempt to set canvas camera
|
||||
try
|
||||
{
|
||||
Canvas c = settingsInstance.GetComponentInChildren<Canvas>(true);
|
||||
if (c != null)
|
||||
{
|
||||
Camera[] cams = GameObject.FindObjectsOfType<Camera>();
|
||||
if (cams != null && cams.Length > 0)
|
||||
{
|
||||
c.worldCamera = cams[0];
|
||||
}
|
||||
cams = null;
|
||||
c = null;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
settingsInstance.SetActive(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Toggle active state
|
||||
bool active = settingsInstance.activeSelf;
|
||||
settingsInstance.SetActive(!active);
|
||||
}
|
||||
|
||||
private void InstantiatePrefab(GameObject prefab)
|
||||
{
|
||||
if (prefab != null && putPrefabsHere != null)
|
||||
{
|
||||
Instantiate(prefab, putPrefabsHere.transform);
|
||||
GameObject instance = Instantiate(prefab, putPrefabsHere.transform);
|
||||
instance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user