private static void UpdateSelfScripts(MenuCommand cmd) { MyContextMenuTool box = cmd.context as MyContextMenuTool; if (box == null) { Debug.LogError("MyScripts null"); return; } box.X *= 5; }
void OnWizardCreate() // CreateButton 按钮点击回调 { if (Selection.gameObjects.Length == 0) { return; } int count = 0; EditorUtility.DisplayProgressBar("修改值的进度条", "当前值进度", (float)count / Selection.gameObjects.Length); foreach (GameObject gameObject in Selection.gameObjects) { MyContextMenuTool tool = gameObject.GetComponent <MyContextMenuTool>(); // 指定撤销对象,指定这一步撤销的名字,在Undo列表中可见 Undo.RecordObject(tool, "MyNameUndo"); tool.X += Value; count++; EditorUtility.DisplayProgressBar("修改值的进度条", "当前值进度", (float)count / Selection.gameObjects.Length); } //EditorUtility.ClearProgressBar(); // 太快了,就用注释看一下,正常需要关闭 EditorPrefs.SetFloat("MyWizardTool.Value", Value); }