Script屬性是基于IDE的一系列編譯器屬性JS中用@script屬性方法()訪問,c#中用[屬性方法()]訪問。一共就只有9種屬性訪問方式:
---------------------------------------------------------------------------------------------------------------------------------------------------------------AddComponentMenu用法:@scriptAddComponentMenu("Transform/FollowTransform")classFollowTransform:MonoBehaviour{}用處:可以自己開發組件類,在菜單里往GameObject里添加組件實例。------------------------------------------------------------------------------------ContextMenu用法:@ContextMenu("UpdateWaypoints")functionUpdateWaypoints(){}用處:使用當前腳本時候可以用右鍵菜單觸發開發環境中運行的函數----------------------------------------------------------------------------------------ExecuteInEditMode用法:@scriptExecuteInEditMode()用處:使當前腳本可以在運行中實時更新修改,每幀都會重新導入腳本,可以方便調試使用。----------------------------------------------------------------------------------------HideInInspector用法:@HideInInspectorvarp=5;用處:是變量在檢測時不被顯示,但是會被實例化??具體用處不詳,猜測為在腳本外部變量設置的時候不會被顯示,但是會被作用到-------------------------------------------------------------------------------------------NonSerialized用處:標記一個變量不會被序列化。具體用處不詳,我理解為不會被外部改變但是可以保持public狀態-------------------------------------------------------------------------------------------RPC什么鬼東西-.-RPC火箭筒?還是標記他用RPC協議傳輸?反正官網什么都沒寫。-------------------------------------------------------------------------------------------RenderBeforeQueues用法:@RenderBeforeQueues(1000,2000)functionOnRenderObject(queue:int){//dosomecustomrendering...}用處:在引擎渲染之前添加一個自定義的渲染具體用法不詳,里頭能用什么東西渲染我也不清楚,還有那個參數我也沒搞明白,以后用到再說吧--------------------------------------------------------------------------------------------RequireComponent用法:js:@ScriptRequireComponent(Rigidbody)c#:[RequireComponent(typeof(Rigidbody))]用處:強制添加一個組件到這個object上,如果存在,則該組件不允許被刪除。-------------------------------------------------------------------------------------------Serializable用法:js繼承Object類默認就是會被序列化classTestextendsSystem.Object{varp=5;varc=Color.white;}vartest=Test();//C#Example[System.Serializable]classTest{publicintp=5;publicColorc=Color.white;}
新聞熱點
疑難解答