notebook实装功能,galgame继续,一些bug修复
This commit is contained in:
@@ -28,6 +28,7 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
|
||||
[SerializeField] GameObject ui_Panel_Character;
|
||||
[SerializeField] Button button_Encyclopendia;
|
||||
[SerializeField] GameObject ui_Panel_Encyclopendia;
|
||||
[SerializeField] Transform notebook_father;
|
||||
[SerializeField] Image image_Character;
|
||||
[SerializeField] Button button_Mail;
|
||||
[SerializeField] GameObject ui_Panel_Mail;
|
||||
@@ -41,6 +42,9 @@ 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] float prefab_Enter_Time = 0.35f;
|
||||
[SerializeField] float prefab_Enter_Scale_From = 0.92f;
|
||||
[SerializeField] Ease prefab_Enter_Ease = Ease.OutCubic;
|
||||
|
||||
[SerializeField] Button button_Idol;
|
||||
[SerializeField] Button button_Select_Music;
|
||||
@@ -240,6 +244,7 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
|
||||
readonly List<Tween> jiantou_Flash_Tweens = new();
|
||||
readonly List<UI_ButtonTween> button_Tweeners = new();
|
||||
bool selectScene_Loading;
|
||||
GameObject encyclopedia_Instance;
|
||||
|
||||
protected override void In_Init()
|
||||
{
|
||||
@@ -302,8 +307,7 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
|
||||
button_Encyclopendia.onClick.AddListener(
|
||||
() =>
|
||||
{
|
||||
gNotice.warning.display("此版本未开放该功能");
|
||||
//Try_Open_Panel(ui_Panel_Encyclopendia);
|
||||
Try_Open_Prefab(ui_Panel_Encyclopendia, ref encyclopedia_Instance);
|
||||
});
|
||||
if (button_Story != null)
|
||||
button_Story.onClick.AddListener(
|
||||
@@ -350,6 +354,56 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
|
||||
panel.SetActive(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
GameObject Try_Open_Prefab(GameObject prefab, ref GameObject instance)
|
||||
{
|
||||
if (prefab == null) return null;
|
||||
if (instance == null)
|
||||
{
|
||||
var parent = notebook_father != null ? notebook_father : (transform.parent != null ? transform.parent : transform);
|
||||
instance = Instantiate(prefab, parent);
|
||||
}
|
||||
AssignPrefabCanvasCamera(instance);
|
||||
if (!instance.activeSelf) instance.SetActive(true);
|
||||
Play_Prefab_Enter(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
void AssignPrefabCanvasCamera(GameObject instance)
|
||||
{
|
||||
if (instance == null) return;
|
||||
var canvases = instance.GetComponentsInChildren<Canvas>(true);
|
||||
if (canvases == null || canvases.Length == 0) return;
|
||||
Camera targetCamera = Camera.main;
|
||||
if (targetCamera == null)
|
||||
{
|
||||
var cams = Camera.allCameras;
|
||||
if (cams != null && cams.Length > 0) targetCamera = cams[0];
|
||||
}
|
||||
if (targetCamera == null) return;
|
||||
for (int i = 0; i < canvases.Length; i++)
|
||||
{
|
||||
var canvas = canvases[i];
|
||||
if (canvas == null) continue;
|
||||
canvas.worldCamera = targetCamera;
|
||||
}
|
||||
}
|
||||
|
||||
void Play_Prefab_Enter(GameObject panel)
|
||||
{
|
||||
if (panel == null) return;
|
||||
var rect = panel.transform as RectTransform;
|
||||
if (rect == null) rect = panel.GetComponent<RectTransform>();
|
||||
if (rect == null) return;
|
||||
rect.DOKill();
|
||||
var cg = panel.GetComponent<CanvasGroup>();
|
||||
if (cg == null) cg = panel.AddComponent<CanvasGroup>();
|
||||
cg.DOKill();
|
||||
rect.localScale = Vector3.one * prefab_Enter_Scale_From;
|
||||
cg.alpha = 0f;
|
||||
rect.DOScale(Vector3.one, prefab_Enter_Time).SetEase(prefab_Enter_Ease);
|
||||
cg.DOFade(1f, prefab_Enter_Time).SetEase(prefab_Enter_Ease);
|
||||
}
|
||||
void Try_Load_Select_Scene()
|
||||
{
|
||||
if (selectScene_Loading)
|
||||
|
||||
Reference in New Issue
Block a user