iLMS知識社群歷程檔登入
位置: 黃國哲 > Unity
1090715 開啟隱藏和隱藏物件
by 黃國哲 2020-07-15 21:11:47, 回應(0), 人氣(596)


這個功能可以用來設計小視窗



步驟一:將以下語法貼到大範圍的Image底下,然後設定兩個Button

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class setactive : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {}
    // Update is called once per frame
    void Update()
    {}

    public GameObject Map ; //拖曳要控制的物件

    public void Active_Map()
    {
        Map.SetActive(true);    
    }

    public void DeActive_Map()
    {
        Map.SetActive(false);    
    }
}


步驟二:將要控制的物件拉到Public後的指定物件位置完成匹配



步驟三:執行後便可以操作了









回應