docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class HierarchicalSphere

    Provide a gizmo/handle representing a box where all face can be moved independently. Also add a contained sub gizmo/handle box if contained is used at creation.

    Inheritance
    object
    HierarchicalSphere
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEditor.Rendering
    Assembly: Unity.RenderPipelines.Core.Editor.dll
    Syntax
    public class HierarchicalSphere
    Examples
    class MyComponentEditor : Editor
    {
        static HierarchicalSphere sphere;
        static HierarchicalSphere containedSphere;
    
        static MyComponentEditor()
        {
            Color[] handleColors = new Color[]
            {
                Color.red,
                Color.green,
                Color.Blue,
                new Color(0.5f, 0f, 0f, 1f),
                new Color(0f, 0.5f, 0f, 1f),
                new Color(0f, 0f, 0.5f, 1f)
            };
            sphere = new HierarchicalSphere(new Color(1f, 1f, 1f, 0.25));
            containedSphere = new HierarchicalSphere(new Color(1f, 0f, 1f, 0.25), container: sphere);
        }
    
        [DrawGizmo(GizmoType.Selected|GizmoType.Active)]
        void DrawGizmo(MyComponent comp, GizmoType gizmoType)
        {
            sphere.center = comp.transform.position;
            sphere.size = comp.transform.scale;
            sphere.DrawHull(gizmoType == GizmoType.Selected);
    
            containedSphere.center = comp.innerposition;
            containedSphere.size = comp.innerScale;
            containedSphere.DrawHull(gizmoType == GizmoType.Selected);
        }
    
        void OnSceneGUI()
        {
            EditorGUI.BeginChangeCheck();
    
            //container sphere must be also set for contained sphere for clamping
            sphere.center = comp.transform.position;
            sphere.size = comp.transform.scale;
            sphere.DrawHandle();
    
            containedSphere.center = comp.innerposition;
            containedSphere.size = comp.innerScale;
            containedSphere.DrawHandle();
    
            if(EditorGUI.EndChangeCheck())
            {
                comp.innerposition = containedSphere.center;
                comp.innersize = containedSphere.size;
            }
        }
    }

    Constructors

    Name Description
    HierarchicalSphere(Color, HierarchicalSphere)

    Constructor. Used to setup colors and also the container if any.

    Properties

    Name Description
    baseColor

    The baseColor used to fill hull. All other colors are deduced from it.

    center

    The position of the center of the box in Handle.matrix space.

    radius

    The size of the box in Handle.matrix space.

    Methods

    Name Description
    DrawHandle()

    Draw the manipulable handles

    DrawHull(bool)

    Draw the hull which means the boxes without the handles

    Extension Methods

    AnalyticsUtils.ToNestedColumnWithDefault<T>(T, T, bool)
    In This Article
    Back to top
    Copyright © 2023 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)