Version: 2022.3
public void ShowUtility ();

描述

将 EditorWindow 显示为浮动实用程序窗口。

当实用程序窗口失去焦点时,它仍然位于新活动窗口的顶部。这意味着, Unity 编辑器永远不会隐藏 EditorWindow.ShowUtility 窗口。但是,该窗口不能 停靠到编辑器。

实用程序窗口将始终位于正常 Unity 窗口前方。该窗口会 在用户从 Unity 切换到其他应用程序时隐藏起来。

**注意**:在使用此函数显示窗口之前,无需使用 EditorWindow.GetWindow

\ 允许您随机设置选定对象的旋转的浮动窗口实用程序。

using UnityEditor;
using UnityEngine;
using System.Collections;

// Simple script that randomizes the rotation of the selected GameObjects. // It also lists which objects are currently selected.

public class RandomizeInSelection : EditorWindow { public float rotationAmount = 0.33f; public string selected = "";

[MenuItem("Example/Randomize Children In Selection")] static void RandomizeWindow() { RandomizeInSelection window = ScriptableObject.CreateInstance(typeof(RandomizeInSelection)) as RandomizeInSelection; window.ShowUtility(); }

void RandomizeSelected() { foreach (var transform in Selection.transforms) { Quaternion rotation = Random.rotation; transform.localRotation = Quaternion.Slerp(transform.localRotation, rotation, rotationAmount); } }

void OnGUI() { foreach (var t in Selection.transforms) { selected += t.name + " "; }

EditorGUILayout.LabelField("Selected Object:", selected); selected = "";

if (GUILayout.Button("Randomize!")) RandomizeSelected();

if (GUILayout.Button("Close")) Close(); }

void OnInspectorUpdate() { Repaint(); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961