UAC2015W100912SourceUAC2015W100912章节.pptxVIP

  • 2
  • 0
  • 约4.68千字
  • 约 22页
  • 2017-11-27 发布于广东
  • 举报
第09-12课 编辑器界面功能扩展 —编辑器;课程名称 Lesson Title 编辑器界面功能扩展 学习者等级 Learner Level 专业能力认证课程 模块 Module 编辑器 本课时长 Duration 180分钟;学习者背景 Learner Background 本课程要求学习者熟悉Unity用户界面,对编辑器类有简单了解。 教学目标 Objectives ? 能够熟练运用编辑器的拓展功能;主题 Topics ;在编辑器中访问选择对象;using UnityEngine; using UnityEditor; public class LookAtMainCamera : ScriptableObject { [MenuItem (Example/Selection looks at Main Camera _l)] static void Look() { Camera camera = Camera.main; if (camera) { foreach (Transform transform in Selection.transforms) { Undo.RegisterUndo(transform, + Looks at Main Camera ); transform.LookAt(camera.transform); } } } //The menu item will be disabled if nothing, is selected. //菜单项目将会失去效用,如果没有事物被选择。 [MenuItem (Example/Selection looks at Main Camera _l, true)] static bool ValidateSelection () { return Selection.transforms.Length != 0; } };SelectionMode类;主题 Topics ;Undo;方法;using UnityEngine; using UnityEditor; //Performs an Undo the number of times specified. //执行指定的撤销次数 public class PerformVariousUndo : ScriptableWizard { public int numberOfSteps = 5; [MenuItem (Example/Perform Various Undo %#u)] static void ExecuteMenu() { ScriptableWizard.DisplayWizard( Perform various Undo at the same time, typeof(PerformVariousUndo), Undo!); } void OnWizardCreate() { // We have to make this in order to make the undo // dont reset the value entered in the inspector int savedNumberOfSteps = numberOfSteps + 1; for(int i = 0; i savedNumberOfSteps; i++) { Undo.PerformUndo(); } } };主题 Topics ;MonoScript;using UnityEngine; using UnityEditor; using System.Collections; public class MonoScriptTest : EditorWindow{ MonoScript sc; [MenuItem (Example/MonoScriptTest)] static void Init() { EditorWindow window = EditorWindow.GetWindow(typeof(MonoScriptTest)); window.Show(); } void OnGUI() { sc = EditorGUILayout.ObjectField(Component, sc, typeof(MonoScript)) as MonoScript; if(GUILayout.Button(Add t

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档