Пример #1
0
        public override void OnToolGUI(EditorWindow window)
        {
            var view = window as SceneView;

            if (!view || !Selection.activeTransform || Tools.s_Hidden)
            {
                return;
            }

            if (!StageUtility.IsGameObjectRenderedByCamera(Selection.activeTransform.gameObject, Camera.current))
            {
                return;
            }

            bool isStatic = (!Tools.s_Hidden && EditorApplication.isPlaying && GameObjectUtility.ContainsStatic(Selection.gameObjects));

            using (new EditorGUI.DisabledScope(isStatic))
            {
                Vector3 handlePosition = Tools.handlePosition;

                ToolGUI(view, handlePosition, isStatic);

                Handles.ShowStaticLabelIfNeeded(handlePosition);
            }
        }
        // Draw Reflection probe preview sphere
        private void OnPreSceneGUICallback(SceneView sceneView)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            foreach (var t in targets)
            {
                ReflectionProbe p = (ReflectionProbe)t;
                if (!reflectiveMaterial)
                {
                    return;
                }

                if (!StageUtility.IsGameObjectRenderedByCamera(p.gameObject, Camera.current))
                {
                    return;
                }

                Matrix4x4 m = new Matrix4x4();

                // @TODO: use MaterialPropertyBlock instead - once it actually works!
                // Tried to use MaterialPropertyBlock in 5.4.0b2, but would get incorrectly set parameters when using with Graphics.DrawMesh
                if (!m_CachedGizmoMaterials.ContainsKey(p))
                {
                    m_CachedGizmoMaterials.Add(p, Instantiate(reflectiveMaterial));
                }
                Material mat = m_CachedGizmoMaterials[p] as Material;
                if (!mat)
                {
                    return;
                }
                {
                    // Get mip level
                    float            mipLevel      = 0.0F;
                    TextureInspector cubemapEditor = m_CubemapEditor as TextureInspector;
                    if (cubemapEditor)
                    {
                        mipLevel = cubemapEditor.GetMipLevelForRendering();
                    }

                    mat.SetTexture("_MainTex", p.texture);
                    mat.SetMatrix("_CubemapRotation", Matrix4x4.identity);
                    mat.SetFloat("_Mip", mipLevel);
                    mat.SetFloat("_Alpha", 0.0f);
                    mat.SetFloat("_Intensity", GetProbeIntensity(p));

                    // draw a preview sphere that scales with overall GO scale, but always uniformly
                    var scale = p.transform.lossyScale.magnitude * 0.5f;
                    m.SetTRS(p.transform.position, Quaternion.identity, new Vector3(scale, scale, scale));
                    Graphics.DrawMesh(sphereMesh, m, mat, 0, SceneView.currentDrawingSceneView.camera, 0);
                }
            }
        }
        void SetHandleVisibility()
        {
            if (m_Handle == null)
            {
                return;
            }

            m_Handle.gameObject.SetActive(
                m_ElevationRelation.isActiveAndEnabled &&
                m_HandleMode != HandleMode.Hidden &&
                StageUtility.IsGameObjectRenderedByCamera(m_ElevationRelation.gameObject, SceneView.lastActiveSceneView.camera));
        }
Пример #4
0
        private static void StaticOnSceneGUI(SceneView view)
        {
            if (!s_ShowNavigation)
            {
                return;
            }

            Selectable[] allSelectablesArray = Selectable.allSelectablesArray;
            foreach (Selectable selectable in allSelectablesArray)
            {
                if (StageUtility.IsGameObjectRenderedByCamera(selectable.gameObject, Camera.current))
                {
                    DrawNavigationForSelectable(selectable);
                }
            }
        }