Version: 2022.2
言語: 日本語

説明

Validates whether custom bounds can be calculated for this Editor.

Use this to validate if Editor.OnGetFrameBounds should be called for this window. The Scene view calls `HasFrameBounds` and `OnGetFrameBounds` when the Frame action is invoked. The Frame action can be called from anywhere, but it is commonly called when you press the F key to frame the selected GameObject.

using UnityEngine;
using UnityEditor;

// This example traverses all bones in the hierarchy and calculates bounds for the entire object public class GameObjectEditorWindow: Editor { private bool HasFrameBounds() { // the result of this function depends on implementation // it will most likely be used to evaluate whether bounds // can exist for the targets of this Editor Window return Selection.objects.Length > 0; }

public Bounds OnGetFrameBounds() { Transform bone = Selection.activeTransform; Bounds bounds = new Bounds(bone.position, new Vector3(0, 0, 0)); foreach (Transform child in bone) bounds.Encapsulate(child.position);

if (bone.parent) bounds.Encapsulate(bone.parent.position);

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