从 Scene2 回到 Scene1 ,不需要重载Scene1,直接回到 想要回到的面板
1、创建一个 全局的脚本
global.cs2
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class Global
{
//仅显示一个面板
public static bool ShowOnlyLevelPanel { get; set; }
{
2、创建一个 响应事件的脚本
GameSceneManager.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameSceneManager : MonoBehaviour
{
public void SceneBackStartGameToMapSelect()
{
Globle.ShowOnlyLevelPanel = true;
SceneManager.LoadScene("StartGame");
}
}
3. 创建 一个 具体执行的脚本
GameManager.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
void Start()
{
Panel1 = Panels.MainPanleAni;
if(Globle.ShowOnlyLevelPanel)
{
//只显示 MapSelect 一个面板
Panel1 = Panels.MapSelect;
//清除全局变量(可省)
Globle.ShowOnlyLevelPanel = false;
}
}
}