美文网首页
unity Inspector属性面板 组件启用与关闭

unity Inspector属性面板 组件启用与关闭

作者: GB_speak | 来源:发表于2018-10-19 16:52 被阅读30次

    https://docs.unity3d.com/ScriptReference/GameObject-activeSelf.html
    https://docs.unity3d.com/ScriptReference/GameObject.SetActive.html

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class CubeApp : MonoBehaviour {
    
        public BoxCollider box;
        public bool lll = true;
        // Use this for initialization
        void Start () {
            
            AppMain.kaishi += kaishi;
            box = this.gameObject.GetComponent<BoxCollider>();
        }
    
        public void kaishi(string name)
        {
            this.transform.Rotate(Vector3.up*10);
            if (lll == true)
            {
                box.enabled = true;
                lll = false;
            }
            else
            {
                box.enabled = false;
                lll = true;
            }
            Debug.Log("开始~~~~"+name);
        }
       
        
        // Update is called once per frame
        void Update () {
            
        }
    }
    
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    
    
    public delegate void KaiShiEventHandler(string name);
    
    public class AppMain : MonoBehaviour {
    
       
        public static event KaiShiEventHandler kaishi;
      
        public Button but;
    
        public int i = 0;
        // Use this for initialization
        void Start ()
        {
            but.onClick.AddListener(OnClick);
        }
    
        public void OnClick()
        {
            kaishi("ddddddddd~");
        }
        
        // Update is called once per frame
        void Update ()
        {
            
        }
    }
    
    

    相关文章

      网友评论

          本文标题:unity Inspector属性面板 组件启用与关闭

          本文链接:https://www.haomeiwen.com/subject/zkhuzftx.html