add ckg
plantilla base para movimiento básico
This commit is contained in:
195
Assets/Game Kit Controller/Scripts/Menu/sceneLoadSystem.cs
Normal file
195
Assets/Game Kit Controller/Scripts/Menu/sceneLoadSystem.cs
Normal file
@@ -0,0 +1,195 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class sceneLoadSystem : MonoBehaviour
|
||||
{
|
||||
public GameObject mainMenuContent;
|
||||
public GameObject sceneLoadMenu;
|
||||
public GameObject sceneSlotPrefab;
|
||||
public Transform sceneSlotsParent;
|
||||
public Scrollbar mainScrollbar;
|
||||
public ScrollRect mainScrollRect;
|
||||
public List<sceneInfo> sceneInfoList = new List<sceneInfo> ();
|
||||
|
||||
public int startingSceneIndex = 1;
|
||||
public bool addSceneNumberToName = true;
|
||||
|
||||
public bool instantiateScenePanelsActivated = true;
|
||||
|
||||
|
||||
public bool useLoadScreen;
|
||||
|
||||
public int loadScreenScene = 1;
|
||||
|
||||
public bool useLastSceneIndexAsLoadScreen = true;
|
||||
|
||||
public string sceneToLoadAsyncPrefsName = "SceneToLoadAsync";
|
||||
|
||||
public bool checkLoadingScreenSceneConfigured = true;
|
||||
|
||||
public string loadingScreenSceneName = "Loading Screen Scene";
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (instantiateScenePanelsActivated) {
|
||||
int demoNumber = 0;
|
||||
|
||||
int sceneInfoListCount = sceneInfoList.Count;
|
||||
|
||||
for (int i = 0; i < sceneInfoListCount; i++) {
|
||||
if (sceneInfoList [i].addSceneToList) {
|
||||
GameObject newSceneSlot = (GameObject)Instantiate (sceneSlotPrefab, Vector3.zero, Quaternion.identity);
|
||||
newSceneSlot.name = "Scene Slot " + (i + 1);
|
||||
newSceneSlot.transform.SetParent (sceneSlotsParent);
|
||||
newSceneSlot.transform.localScale = Vector3.one;
|
||||
newSceneSlot.transform.position = newSceneSlot.transform.position;
|
||||
|
||||
sceneSlotInfo newSceneSlotInfo = newSceneSlot.GetComponent<sceneSlot> ().sceneSlotInfo;
|
||||
|
||||
if (addSceneNumberToName) {
|
||||
newSceneSlotInfo.sceneNameText.text = (demoNumber + 1) + " - " + sceneInfoList [i].Name;
|
||||
} else {
|
||||
newSceneSlotInfo.sceneNameText.text = sceneInfoList [i].Name;
|
||||
}
|
||||
|
||||
if (sceneInfoList [i].titleFontSize > 0) {
|
||||
newSceneSlotInfo.sceneNameText.fontSize = sceneInfoList [i].titleFontSize;
|
||||
}
|
||||
|
||||
newSceneSlotInfo.sceneDescriptionText.text = sceneInfoList [i].sceneDescription;
|
||||
|
||||
newSceneSlotInfo.sceneDescriptionText.fontSize = sceneInfoList [i].fontSize;
|
||||
|
||||
newSceneSlotInfo.sceneImage.texture = sceneInfoList [i].sceneImage;
|
||||
|
||||
sceneInfoList [i].sceneButton = newSceneSlotInfo.sceneButton;
|
||||
|
||||
demoNumber++;
|
||||
}
|
||||
}
|
||||
|
||||
sceneSlotPrefab.SetActive (false);
|
||||
|
||||
StartCoroutine (SetValue ());
|
||||
}
|
||||
}
|
||||
|
||||
public void loadScene (Button buttonToCheck)
|
||||
{
|
||||
mainMenuContent.SetActive (false);
|
||||
|
||||
int sceneInfoListCount = sceneInfoList.Count;
|
||||
|
||||
for (int i = 0; i < sceneInfoListCount; i++) {
|
||||
if (sceneInfoList [i].sceneButton == buttonToCheck) {
|
||||
GKC_Utils.loadScene (sceneInfoList [i].sceneNumber, useLoadScreen, loadScreenScene, sceneToLoadAsyncPrefsName,
|
||||
useLastSceneIndexAsLoadScreen, checkLoadingScreenSceneConfigured, loadingScreenSceneName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator SetValue ()
|
||||
{
|
||||
yield return new WaitForEndOfFrame ();
|
||||
|
||||
sceneLoadMenu.SetActive (true);
|
||||
|
||||
mainScrollRect.verticalNormalizedPosition = 0f;
|
||||
mainScrollRect.horizontalNormalizedPosition = 0.5f;
|
||||
mainScrollRect.horizontalNormalizedPosition = 0.5f;
|
||||
mainScrollbar.value = 0;
|
||||
|
||||
sceneLoadMenu.SetActive (false);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
public void setSceneNumberInOrder ()
|
||||
{
|
||||
int sceneInfoListCount = sceneInfoList.Count;
|
||||
|
||||
for (int i = 0; i < sceneInfoListCount; i++) {
|
||||
sceneInfoList [i].sceneNumber = (i + startingSceneIndex);
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setSceneNumberInOrderByIndex (int index)
|
||||
{
|
||||
int currentIndex = 0;
|
||||
|
||||
int sceneInfoListCount = sceneInfoList.Count;
|
||||
|
||||
for (int i = 0; i < sceneInfoListCount; i++) {
|
||||
if (i >= index) {
|
||||
sceneInfoList [i].sceneNumber = (currentIndex + startingSceneIndex);
|
||||
|
||||
currentIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void enableAddSceneToListByIndex (int index)
|
||||
{
|
||||
int sceneInfoListCount = sceneInfoList.Count;
|
||||
|
||||
for (int i = 0; i < sceneInfoListCount; i++) {
|
||||
if (i >= index) {
|
||||
sceneInfoList [i].addSceneToList = true;
|
||||
}
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void disableAddSceneToListByIndex (int index)
|
||||
{
|
||||
int sceneInfoListCount = sceneInfoList.Count;
|
||||
|
||||
for (int i = 0; i < sceneInfoListCount; i++) {
|
||||
if (i >= index) {
|
||||
sceneInfoList [i].addSceneToList = false;
|
||||
}
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Scene Load System", gameObject);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class sceneInfo
|
||||
{
|
||||
public string Name;
|
||||
[TextArea (10, 25)] public string sceneDescription;
|
||||
public int sceneNumber;
|
||||
public Texture sceneImage;
|
||||
public Button sceneButton;
|
||||
public bool addSceneToList = true;
|
||||
|
||||
public int fontSize = 20;
|
||||
|
||||
public int titleFontSize = 0;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class sceneSlotInfo
|
||||
{
|
||||
public Text sceneNameText;
|
||||
public Text sceneDescriptionText;
|
||||
public RawImage sceneImage;
|
||||
public Button sceneButton;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user