103 lines
2.2 KiB
C#
103 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
public class HoldToolsCheck : MonoBehaviour
|
|
{
|
|
public List<string> 持有工具 = new List<string>();
|
|
public int 工具选择得分 = 0;
|
|
public bool 已得分 ;
|
|
public GameObject[] 只在工具间激活;
|
|
public GameObject[] 只在主场景激活;
|
|
public GameObject 工具面板;
|
|
public bool first = true;
|
|
//[SerializeField]
|
|
public static HoldToolsCheck Instance { get; set; }//单例
|
|
private string scenename_old;
|
|
private string scenename_new;
|
|
private void Awake()
|
|
{
|
|
if (Instance != null)
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
else
|
|
{
|
|
Instance = this;
|
|
DontDestroyOnLoad(this);
|
|
}
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
|
|
scenename_old = SceneManager.GetActiveScene().name;
|
|
|
|
|
|
|
|
if (scenename_old != scenename_new)
|
|
{
|
|
if (SceneManager.GetActiveScene().name == "工具间场景")
|
|
{
|
|
for (int i = 0; i < 只在工具间激活.Length; i++)
|
|
{
|
|
|
|
只在工具间激活[i].gameObject.SetActive(true);
|
|
|
|
|
|
}
|
|
for (int i = 0; i < 只在主场景激活.Length; i++)
|
|
{
|
|
|
|
只在主场景激活[i].gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
}
|
|
else {
|
|
|
|
|
|
|
|
for (int i = 0; i < 只在主场景激活.Length; i++)
|
|
{
|
|
|
|
只在主场景激活[i].gameObject.SetActive(true);
|
|
|
|
|
|
}
|
|
for (int i = 0; i < 只在工具间激活.Length; i++)
|
|
{
|
|
|
|
只在工具间激活[i].gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
scenename_new = SceneManager.GetActiveScene().name;
|
|
}
|
|
public void Scenload(string scenename) {
|
|
|
|
|
|
SceneManager.LoadScene(scenename);
|
|
if (GameObject.Find("GameManager_Tools"))
|
|
{ GameObject.Find("GameManager_Tools").GetComponent<GameManager_Tools>().fenshu_check(); }
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|