<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## **MonoBehaviour** 繼承關系:MonoBehaviour》 Behaviour類》Component類》Object類 MonoBehaviour是一個基類,所有Unity腳本都派生自該類。 使用C#時,必須顯式從MonoBehaviour派生。使用UnityScript (一種JavaScript)時,則不必從MonoBehaviour顯式派生。 >[danger]注意: Unity Editor中有一個用于禁用MonoBehaviour的復選框。如果取消選中該復選框,則禁用其相關函數。如果腳本中不存在以下任一函數, Editor將不顯示該復選框: Start() Update() FixedUpdate() LateUpdate() OnGU() OnDisable() OnEnable() ## **停用游戲對象** 可以通過將游戲對象標記為非活動來暫時從場景中移除此用腳本的**GameObject**.[activeSelf](https://docs.unity3d.com/ScriptReference/GameObject-activeSelf.html)屬性\(通過**GameObject**.[SetActive](https://docs.unity3d.com/ScriptReference/GameObject.SetActive.html)\)或者使用Inspector中的激活復選框來即取消**游戲對象**的名稱左邊的復選框(見下圖)。 ![](https://img.kancloud.cn/f9/f9/f9f91fa90d815a529df5b20566dbd0ad_327x103.png) ## **停用父GameObject** 停用父對象時,停用也會覆蓋其所有子對象上的activeSelf設置,因此父級的整個層級視圖將變為非活動狀態。請注意,這不會更改子對象上activeSelf屬性的值(即只要父對象為非活動狀態子對象的**GameObject.activeSelf**為**true** 子對象也是非活躍狀態的),因此一旦重新激活父對象,子對象將恢復到其原始狀態。這意味著無法通過讀取activeSelf屬性來確定子對象當前是否在場景中處于活動狀態。而應該使用**GameObject**.[activeInHierarchy](https://docs.unity3d.com/ScriptReference/GameObject-activeInHierarchy.html)屬性,該屬性將考慮父對象的覆蓋效果。 在Unity 4.0中,已引入此覆蓋行為。在早期版本中,有一個稱為**SetActiveRecursively**的函數可用于激活或停用給定父對象的子項。但是,此函數的工作方式不同:每個子對象的激活設置都已更改-可以關閉和打開整個層級視圖,但是子對象無法"記住”自己最初所處的狀態。為了避免破壞舊版代碼, SetActiveRecursively已保留在4.0的API中,但不建議予以使用,而且將來可能會將其移除(2018版本已被移除,可能更早未測試)。 在實際希望更改子游戲對象而不是父對象的**activeSelf**設置(極少情況下),可以使用如下代碼: ~~~ void DeactivateChildren(GameObject g, bool a) { g.activeSelf = a; foreach (Transform child in g.transform) { DeactivateChildren(child.gameObject, a); } } ~~~ ## **Properties** | | | | --- | --- | | [runInEditMode](https://docs.unity3d.com/ScriptReference/MonoBehaviour-runInEditMode.html)| 允許MonoBehaviour的特定實例在編輯模式下運行(僅可在Editor中使用) | | [useGUILayout](https://docs.unity3d.com/ScriptReference/MonoBehaviour-useGUILayout.html)| 禁用該屬性可跳過GUI布局階段。 | ## **Public Methods** | | | | --- | --- | | [CancelInvoke](https://docs.unity3d.com/ScriptReference/MonoBehaviour.CancelInvoke.html)| 取消該MonoBehaviour上的所有Invoke調用。 | | [Invoke](https://docs.unity3d.com/ScriptReference/MonoBehaviour.Invoke.html)| 在秒后調用方法 | | [InvokeRepeating](https://docs.unity3d.com/ScriptReference/MonoBehaviour.InvokeRepeating.html)| 在秒后調用方法,然后每秒調用一次。 | |[IsInvoking](https://docs.unity3d.com/ScriptReference/MonoBehaviour.IsInvoking.html)| | | [StartCoroutine](https://docs.unity3d.com/ScriptReference/MonoBehaviour.StartCoroutine.html)| 是否有任何待處理的調用?Isinvoking啟動一個協同程序。 | | [StopAllCoroutines](https://docs.unity3d.com/ScriptReference/MonoBehaviour.StopAllCoroutines.html)| 停止在該行為上運行的所有協同程序 | | [StopCoroutine](https://docs.unity3d.com/ScriptReference/MonoBehaviour.StopCoroutine.html)| 停止在該行為上運行的第一個名為的協同程序或存儲在中的協同程序。 | ## **Static Methods** | | | | --- | --- | | print | 將消息記錄到Unity控制臺(與DebugLog相同 | ## Messages | | | | --- | --- | | [Awake](https://docs.unity3d.com/ScriptReference/MonoBehaviour.Awake.html) | Awake在加載腳本實例時調用。 | | [FixedUpdate](https://docs.unity3d.com/ScriptReference/MonoBehaviour.FixedUpdate.html) | 如果啟用了MonoBehaviour,則每個固定幀率幀調用該函數。 | | [LateUpdate](https://docs.unity3d.com/ScriptReference/MonoBehaviour.LateUpdate.html) | 如果啟用了Behaviour,則每幀調用LateUpdate. | | [OnAnimatorIK](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnAnimatorIK.html) | 用于設置動畫IK (反向運動學)的回調。 | | [OnAnimatorMove](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnAnimatorMove.html) | 用于處理動畫移動以修改根運動的回調。 | | [OnApplicationFocus](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationFocus.html) | 當玩家獲得或失去焦點時,發送給所有GameObject. | | [OnApplicationPause](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationPause.html) | 程暫停,送所有GameObject. | | [OnApplicationQuit](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationQuit.html) | 在應用程序退出前,發送給所有游戲對象。 | | [OnAudioFilterRead](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnAudioFilterRead.html) |如果實現了OnAudioFilterRead, Unity將在音頻DSP鏈中插入一個自定義濾波 | | [OnBecameInvisible](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnBecameInvisible.html) | OnBecamelnvisible在渲染對任何攝像機都不可見時調用。 | | [OnBecameVisible](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnBecameVisible.html) | OnBecameVisible在渲染變為對任意攝像機可見時調用。 | | [OnCollisionEnter](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter.html) | 當該碰撞體/剛體已開始接觸另一個剛體/碰撞體時,調用OnCollisionEnter. | | [OnCollisionEnter2D](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter2D.html) | 當傳入碰撞體與該對象的碰撞體接觸時發送(僅限2D物理) | | [OnCollisionExit](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionExit.html) | 當該碰撞體/剛體已停止接觸另一個剛體/碰撞體時,調用OnCollisionExit. | | [OnCollisionExit2D](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionExit2D.html) | 當另一個對象上的碰撞體停止接觸該對象的碰撞體時發送(僅限2D物理) | | [OnCollisionStay](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionStay.html) | 對應正在接觸剛體/碰撞體的每一個碰撞體/剛體,每幀調用一次:ref::OnCollisionStay | | [OnCollisionStay2D](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionStay2D.html) | 在另一個對象上的碰撞體正在接觸該對象的碰撞體時發送每個幀(僅限2D物理) | | [OnConnectedToServer](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnConnectedToServer.html) | 成功連接到服務后在客戶端上調用。 | | [OnControllerColliderHit](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnControllerColliderHit.html) | 當該控制在執行Move時撞到碰撞體時調用OnControllerColliderHit. | | [OnDestroy](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDestroy.html) | 銷毀附加的行為將導致游戲或場景收到OnDestroy. | | [OnDisable](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDisable.html) | 該函數在行為被禁用時調用。 | | [OnDisconnectedFromServer](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDisconnectedFromServer.html) | 當連接丟失或與服務斷開連接時,在客戶端上調用。 | | [OnDrawGizmos](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDrawGizmos.html) | 如果您想繪制能夠選擇并且始終繪制的輔助圖標,則可以實現OnDrawGizmos. | | [OnDrawGizmosSelected](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDrawGizmosSelected.html) | 如果選擇了對象,則實現OnDrawGizmosSelected來繪制輔助圖標。 | | [OnEnable](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnEnable.html) | 該函數在對象變為啟用和激活狀態時調用。 | | [OnFailedToConnect](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnFailedToConnect.html) | 出于某種原因連接嘗試失敗時,在客戶端上調用。 | | [OnFailedToConnectToMasterServer](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnFailedToConnectToMasterServer.html) | 在連接到MasterServer時發生問題的情況下,在客戶端或服務上調用。 | | [OnGUI](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnGUI.html) | 系統調用OnGUI來渲染和處理GUI事件。 | | [OnJointBreak](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnJointBreak.html) | 在附加到相同游戲對象的關節斷開時調用。 | | [OnJointBreak2D](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnJointBreak2D.html) | 在附加到相同游戲對象的Joint2D斷開時調用。 | | [OnMasterServerEvent](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMasterServerEvent.html) | 在從MasterServer報告事件時,在客戶端或服務上調用。 | | [OnMouseDown](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseDown.html) | 當用戶在GUElement或Collider上按下鼠標按鈕時,將調用OnMouseDown | | [OnMouseDrag](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseDrag.html) | 當用戶單擊GUElement或Collider并仍然按住鼠標時,將調用OnMouseDrag | | [OnMouseEnter](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseEnter.html) | 當鼠標進入GUElement或Collider時調用。 | | [OnMouseExit](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseExit.html) | 當鼠標懸停在GUElement或Collider上時,每幀調用一次。 | | [OnMouseOver](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseOver.html) | 當鼠標懸停在GUElement或Collider上時,每幀調用一次。 | | [OnMouseUp](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseUp.html) |當用戶松開鼠標按鈕時,將調用OnMouseUp. | | [OnMouseUpAsButton](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseUpAsButton.html) | 松開鼠標時,僅當鼠標在按下時所在的GUIElement或Collider上時,才調用OnMouseUpAsButton. | | [OnNetworkInstantiate](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnNetworkInstantiate.html) | 當粒子擊中碰撞體時,將調用OnParticleCollision. | | [OnParticleCollision](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnParticleCollision.html) | 當粒子擊中碰撞體時,將調用OnParticleCollision. | | [OnParticleSystemStopped(新2019)](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnParticleSystemStopped.html) | OnParticleSystemStopped是在系統中的所有粒子都已死亡,且沒有新粒子生成時調用的。新的粒子會在停止后停止生成,或者當非循環系統的持續時間屬性被超過時停止生成。 | | [OnParticleTrigger](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnParticleTrigger.html) | 當粒子系統中的任何粒子滿足觸發模塊中的條件時,將調用OnParticleTrigger. | | [OnPlayerConnected](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnPlayerConnected.html) | 每當有新玩家成功連接,就在服務上調用。 | | [OnPlayerDisconnected](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnPlayerDisconnected.html) | 每當有玩家與服務斷開連接,就在服務上調用。 | | [OnPostRender](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnPostRender.html) | 在攝像機完成場景渲染后,將調用OnPostRender. | | [OnPreCull](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnPreCull.html) | | | [OnPreRender](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnPreRender.html) | OnPreCull在攝像機剔除場景前調用 | | [OnRenderImage](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnRenderImage.html) | OnRenderimage在圖像的所有渲染操作全部完成后調用。 | | [OnRenderObject](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnRenderObject.html) | OnRenderObject在攝像機渲染場景后調用。 | | [OnSerializeNetworkView](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnSerializeNetworkView.html) | 用于在網絡視圖監視的腳本中自定義變量同步。 | | [OnServerInitialized](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnServerInitialized.html) | 每當調用Network.nitializeServer并且完成時,對該服務調用該函數。 | | [OnTransformChildrenChanged](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTransformChildrenChanged.html) | 當GameObject的變換的子項列表發生更改時,將調用該函數。 | | [OnTransformParentChanged](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTransformParentChanged.html) |當GameObject的變換的父屬性發生更改時,將調用該函數。 | | [OnTriggerEnter](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerEnter.html) | 當 Collider 件進入該觸發時調用OnTriggerEnter. | | [OnTriggerEnter2D](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerEnter2D.html) | 當另一個對象進入附加到該對象的觸發碰撞體時發送(僅限2D物理) | | [OnTriggerExit](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerExit.html) | 當Collider 已停止接觸該觸發時調用OnTriggerExit. | | [OnTriggerExit2D](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerExit2D.html) | 當另一個對象離開附加到該對象的觸發碰撞體時發送(僅限2D物理) | | [OnTriggerStay](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerStay.html) | 對于接觸觸發的每一個Collider /other/,每次物理更新調用一次OnTriggerStay | | [OnTriggerStay2D](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerStay2D.html) | 在另一個對象位于附加到該對象的觸發碰撞體之內時發送每個幀(僅限2D物理) | | [OnValidate](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnValidate.html) | 加載腳本后或Inspector中的值發生更改時,將調用該函數(只能在Editor中調用)。 | | [OnWillRenderObject](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnWillRenderObject.html) | 如果對象可見并且不是UI元素,則為每攝像機調用OnWillRenderObject. | | [Reset](https://docs.unity3d.com/ScriptReference/MonoBehaviour.Reset.html) | 重置為默認值。 | | [Start](https://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html) | 在首次調用任何Update方法之前啟用腳本時,在幀上調用Start | | [Update](https://docs.unity3d.com/ScriptReference/MonoBehaviour.Update.html) | 如果啟用了MonoBehaviour,則每幀調用Update. | # Inherited Members(廢棄) ## Properties | 廢棄的屬性 | | | --- | --- | | [enabled](https://docs.unity3d.com/ScriptReference/Behaviour-enabled.html) | 啟用的Behaviour可更新,禁用的Behaviour不可更新。 | | [isActiveAndEnabled](https://docs.unity3d.com/ScriptReference/Behaviour-isActiveAndEnabled.html) | 已調用啟用的Behaviour. | | [gameObject](https://docs.unity3d.com/ScriptReference/Component-gameObject.html) | 此組件附加到的游戲對象。始終將組件附加到游戲對象。 | | [tag](https://docs.unity3d.com/ScriptReference/Component-tag.html) | 此游戲對象的標簽。 | | [transform](https://docs.unity3d.com/ScriptReference/Component-transform.html) | 附加到此GameObject的Iransform. | | [hideFlags](https://docs.unity3d.com/ScriptReference/Object-hideFlags.html) | 該對象應該隱藏、隨場景一起保存還是由用戶修改? | | [name](https://docs.unity3d.com/ScriptReference/Object-name.html) | 對象的名稱。 | ## Public Methods(廢棄) | | | | --- | --- | | [BroadcastMessage](https://docs.unity3d.com/ScriptReference/Component.BroadcastMessage.html) | 調用此游戲對象或其任何子項中的每個MonoBehaviour上名為的方法。 | | [CompareTag](https://docs.unity3d.com/ScriptReference/Component.CompareTag.html) | 此游戲對象是否使用進行了標記? | | [GetComponent](https://docs.unity3d.com/ScriptReference/Component.GetComponent.html) | 如果游戲對象附加了類型為的組件,則將其返回,否則返回null. | | [GetComponentInChildren](https://docs.unity3d.com/ScriptReference/Component.GetComponentInChildren.html) | 使用深度首次搜索返回GameObject或其任何子項中類型為的組件。 | | [GetComponentInParent](https://docs.unity3d.com/ScriptReference/Component.GetComponentInParent.html) | 返回GameObject或其任何父項中類型為的組件。 | | [GetComponents](https://docs.unity3d.com/ScriptReference/Component.GetComponents.html) | 返回GameObject中類型為的所有組件。 | | [GetComponentsInChildren](https://docs.unity3d.com/ScriptReference/Component.GetComponentsInChildren.html) | 使用深度首次搜索返回GameObject或其任何子項中類型為的組件。 | | [GetComponentsInParent](https://docs.unity3d.com/ScriptReference/Component.GetComponentsInParent.html) | 返回GameObject或其任何子項中類型為的所有組件。 | | [SendMessage](https://docs.unity3d.com/ScriptReference/Component.SendMessage.html) |調用此游戲對象中的每個MonoBehaviour上名為的方法。 | | [SendMessageUpwards](https://docs.unity3d.com/ScriptReference/Component.SendMessageUpwards.html) | 調用此游戲對象中的每個MonoBehaviour上或此行為的每個父級上名為的方法 | | [TryGetComponent(新2019)](https://docs.unity3d.com/ScriptReference/Component.TryGetComponent.html) | 獲取指定類型(如果存在)的組件。 | | [GetInstanceID](https://docs.unity3d.com/ScriptReference/Object.GetInstanceID.html) | 返回對象的實例ID. | | [ToString](https://docs.unity3d.com/ScriptReference/Object.ToString.html) | 返回 GameObject的名稱。 | ## Static Methods | | | | --- | --- | | [Destroy](https://docs.unity3d.com/ScriptReference/Object.Destroy.html) | 刪除GameObject、組件或資源。 | | [DestroyImmediate](https://docs.unity3d.com/ScriptReference/Object.DestroyImmediate.html) | 立即銷毀對象/obj/。強烈建議您改用Destroy. | | [DontDestroyOnLoad](https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html) | 加載新場景時,不自動銷毀對象/target/. | | [FindObjectOfType](https://docs.unity3d.com/ScriptReference/Object.FindObjectOfType.html) | 返回第一個類型為的已加載的激活對象。 | | [FindObjectsOfType](https://docs.unity3d.com/ScriptReference/Object.FindObjectsOfType.html) | 返回所有類型為的已加載的激活對象的列表。 | | [Instantiate](https://docs.unity3d.com/ScriptReference/Object.Instantiate.html) | 克隆對象并返回克隆對象。 | ## Operators | | | | --- | --- | |[bool](https://docs.unity3d.com/ScriptReference/Object-operator_Object.html) | 該對象是否存在? | | [operator !=](https://docs.unity3d.com/ScriptReference/Object-operator_ne.html) | 比較兩個對象是否引用不同的對象。 | | [operator ==](https://docs.unity3d.com/ScriptReference/Object-operator_eq.html) | 比較兩個對象引用,判斷它們是否引用同一個對象。 |
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看