讲解怎么在Unity的Inspector面板中用滑动条来控制变量的大小
1个回答
展开全部
Inspector中的郑蔽变量的视喊亮州图形式一般是固定的,int、float 就是文本框。
要实现你这个功能,要写 UnityEditor 插件(引入 UnityEditor 的 namespace),滑动条是
EditorGUILayout.Slider
//键物 Editor script that lets you scale the selected GameObject between 1 and 100//缩放选择的游戏物体,在1-100之间class EditorGUILayoutSlider extends EditorWindow { var scale : float = 0.0; @MenuItem("Examples/Editor GUILayout Slider usage") static function Init() { var window = GetWindow(EditorGUILayoutSlider); window.Show(); } function OnGUI() { scale = EditorGUILayout.Slider(scale,1, 100); } function OnInspectorUpdate() { if(Selection.activeTransform) Selection.activeTransform.localScale = Vector3(scale, scale, scale); }}
要实现你这个功能,要写 UnityEditor 插件(引入 UnityEditor 的 namespace),滑动条是
EditorGUILayout.Slider
//键物 Editor script that lets you scale the selected GameObject between 1 and 100//缩放选择的游戏物体,在1-100之间class EditorGUILayoutSlider extends EditorWindow { var scale : float = 0.0; @MenuItem("Examples/Editor GUILayout Slider usage") static function Init() { var window = GetWindow(EditorGUILayoutSlider); window.Show(); } function OnGUI() { scale = EditorGUILayout.Slider(scale,1, 100); } function OnInspectorUpdate() { if(Selection.activeTransform) Selection.activeTransform.localScale = Vector3(scale, scale, scale); }}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询