70 lines
2.0 KiB
C#
70 lines
2.0 KiB
C#
using System.Collections;
|
|
using LE_LevelEditor.Core;
|
|
using LE_LevelEditor.Extensions;
|
|
using LapinerTools.uMyGUI;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
namespace LE_LevelEditor.Example
|
|
{
|
|
public class ExampleGame_Game : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private int TERRAIN_LAYER = 28;
|
|
|
|
[SerializeField]
|
|
private LE_TerrainTextureConfig TERRAIN_TEXTURE_CONFIG;
|
|
|
|
[SerializeField]
|
|
private GameObject PLAYER;
|
|
|
|
private void Start()
|
|
{
|
|
ExampleGame_LoadSave.Init();
|
|
LE_ExtensionInterface.Load.Delegate(this, delegate(byte[][] p_levelData)
|
|
{
|
|
if (p_levelData != null && p_levelData.Length > 0 && p_levelData[0] != null)
|
|
{
|
|
LE_SaveLoadData p_loadedLevel = LE_SaveLoad.LoadLevelDataFromByteArray(p_levelData[0], TERRAIN_LAYER, TERRAIN_TEXTURE_CONFIG.TERRAIN_TEXTURES, TERRAIN_TEXTURE_CONFIG.TERRAIN_NORMALS, TERRAIN_TEXTURE_CONFIG.TERRAIN_TEXTURE_SIZES, TERRAIN_TEXTURE_CONFIG.TERRAIN_TEXTURE_OFFSETS);
|
|
LE_SaveLoad.DisableLevelEditing(p_loadedLevel);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("ExampleGame_Game: No saved level found!");
|
|
}
|
|
uMyGUI_PopupManager.Instance.HidePopup("loading");
|
|
GameObject gameObject = GameObject.Find("Objects/PlayerStartPosition");
|
|
if (gameObject != null)
|
|
{
|
|
PLAYER.transform.position = gameObject.transform.position + gameObject.transform.up;
|
|
Object.Destroy(gameObject);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("ExampleGame_Game: could not find a PlayerStartPosition GameObject!");
|
|
}
|
|
}, true);
|
|
}
|
|
|
|
private void OnGUI()
|
|
{
|
|
GUILayout.BeginHorizontal();
|
|
GUILayout.Space(400f);
|
|
if (GUILayout.Button("Back to Editor", GUILayout.Height(40f)))
|
|
{
|
|
StartCoroutine(LateLoadEditor());
|
|
}
|
|
GUILayout.EndHorizontal();
|
|
}
|
|
|
|
private IEnumerator LateLoadEditor()
|
|
{
|
|
base.enabled = false;
|
|
uMyGUI_PopupManager.Instance.ShowPopup("loading");
|
|
yield return new WaitForSeconds(1f);
|
|
ExampleGame_Editor.m_isComingBackFromGame = true;
|
|
SceneManager.LoadScene("LE_ExampleEditor");
|
|
}
|
|
}
|
|
}
|