예제 #1
0
    /// <summary>
    /// 開啟或關閉某個物件 並啟動事件
    /// </summary>
    public void OnOffObj(int n, bool OnOff)
    {
        n = MyCalculate.SaladModInt(n, AllObj.Length);
        if (AllObj [n].obj == null)
        {
            return;
        }

        if (AllObj [n].Open == OnOff)
        {
            return;
        }
        AllObj [n].obj.SetActive(OnOff);
        if (OnOff)
        {
            if (AllObj [n].EnterEvent != null)
            {
                AllObj [n].EnterEvent.Invoke();
            }
        }
        else
        {
            if (AllObj [n].ExitEvent != null)
            {
                AllObj [n].ExitEvent.Invoke();
            }
        }
    }