added gui asset

This commit is contained in:
Lorenzo
2022-08-26 20:56:55 +02:00
parent a50eba6029
commit 16fbf19eef
2948 changed files with 3787843 additions and 25718 deletions

View File

@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace LayerLab.CasualGame
{
public class PanelCasualGame : MonoBehaviour
{
[SerializeField] private GameObject[] otherPanels;
public void OnEnable()
{
for (int i = 0; i < otherPanels.Length; i++) otherPanels[i].SetActive(true);
}
public void OnDisable()
{
for (int i = 0; i < otherPanels.Length; i++) otherPanels[i].SetActive(false);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a17407d58af8dc24fb97e58d33e21a0c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,84 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace LayerLab.CasualGame
{
public class PanelControlCasualGame : MonoBehaviour
{
private int page = 0;
private bool isReady = false;
[SerializeField] private List<GameObject> panels = new List<GameObject>();
private TextMeshProUGUI textTitle;
[SerializeField] private Transform panelTransform;
[SerializeField] private Button buttonPrev;
[SerializeField] private Button buttonNext;
private void Start()
{
textTitle = transform.GetComponentInChildren<TextMeshProUGUI>();
buttonPrev.onClick.AddListener(Click_Prev);
buttonNext.onClick.AddListener(Click_Next);
foreach (Transform t in panelTransform)
{
panels.Add(t.gameObject);
t.gameObject.SetActive(false);
}
panels[page].SetActive(true);
isReady = true;
CheckControl();
}
void Update()
{
if (panels.Count <= 0 || !isReady) return;
if (Input.GetKeyDown(KeyCode.LeftArrow))
Click_Prev();
else if (Input.GetKeyDown(KeyCode.RightArrow))
Click_Next();
}
//Click_Prev
public void Click_Prev()
{
if (page <= 0 || !isReady) return;
panels[page].SetActive(false);
panels[page -= 1].SetActive(true);
textTitle.text = panels[page].name;
CheckControl();
}
//Click_Next
public void Click_Next()
{
if (page >= panels.Count - 1) return;
panels[page].SetActive(false);
panels[page += 1].SetActive(true);
CheckControl();
}
void SetArrowActive()
{
buttonPrev.gameObject.SetActive(page > 0);
buttonNext.gameObject.SetActive(page < panels.Count - 1);
}
//SetTitle, SetArrow Active
private void CheckControl()
{
textTitle.text = panels[page].name.Replace("_", " ");
SetArrowActive();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d8017e348a20ee8488abc4846db0e0cd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: