コード例 #1
0
    private void OnSceneGUI_Bounds()
    {
        if (svo != null &&
            svo.meshFilter != null && svo.meshFilter.sharedMesh != null &&
            svo.sourceMeshFilter != null && svo.sourceMeshFilter.sharedMesh != null &&
            !Application.isPlaying)
        {
            {
                EditorGUI.BeginChangeCheck();

                Mesh   mesh   = svo.meshFilter.sharedMesh;
                Bounds bounds = mesh.bounds;

                if (data == null)
                {
                    data        = new Data();
                    data.exts   = bounds.extents;
                    data.center = bounds.center;
                }

                Handles.matrix = svo.transform.localToWorldMatrix;

                Vector3 center = data.center;
                Vector3 exts   = data.exts;

                exts = Handles.ScaleHandle(exts, center, Quaternion.identity, 1);

                center.z -= exts.z;
                center    = Handles.PositionHandle(center, Quaternion.identity);
                center.z += exts.z;

                DrawBounds(Color.black, svo.transform.localToWorldMatrix, center, exts);

                exts.x = Mathf.Max(exts.x, 0.01f);
                exts.y = Mathf.Max(exts.y, 0.01f);
                exts.z = Mathf.Max(exts.z, 0.01f);

                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(data, "Shadow Volume Bounds Edit");
                    data.exts      = exts;
                    data.center    = center;
                    bounds.extents = data.exts;
                    bounds.center  = data.center;
                    mesh.bounds    = bounds;
                    ShadowVolumeSetting.MarkSceneAsDirty();
                }
            }

            {
                Mesh    mesh   = svo.sourceMeshFilter.sharedMesh;
                Bounds  bounds = mesh.bounds;
                Vector3 exts   = bounds.extents;
                Vector3 center = bounds.center;

                DrawBounds(Color.white, svo.source.transform.localToWorldMatrix, center, exts);
            }
        }
    }
コード例 #2
0
 private static void Init()
 {
     if (s_instance == null)
     {
         s_instance         = EditorWindow.CreateInstance <ShadowVolumeSetting>();
         s_instance.name    = "Shadow Volume Setting";
         s_instance.minSize = new Vector2(480, 400);
         s_instance.maxSize = new Vector2(480, 400);
     }
     s_instance.ShowUtility();
 }