1100514 開啟關閉物件的腳本
by 黃國哲
2021-05-14 16:13:48, 回應(0), 人氣(677)

https://www.gameislearning.url.tw/article_content.php?getb=2&foog=9997
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class 抓取腳本 : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void 抓取腳本開啟btn()
{ GameObject.Find("Camera").GetComponent<PlayerMovement>().enabled = true; }
public void 抓取腳本關閉btn()
{ GameObject.Find("Camera").GetComponent<PlayerMovement>().enabled = false;}
}
/////////////////////////////////////////
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class openclosescript : MonoBehaviour
{
// Start is called before the first frame update
public GameObject player ;
public void 抓取腳本開啟btn()
{ player.GetComponent<PlayerMovement>().enabled = true; }
public void 抓取腳本關閉btn()
{ player.GetComponent<PlayerMovement>().enabled = false;}
}
回應