public void OnSceneViewGUI()
 {
     if (this.m_Modules != null)
     {
         ParticleSystem[] particleSystems = this.m_ParticleSystems;
         for (int i = 0; i < particleSystems.Length; i++)
         {
             ParticleSystem particleSystem = particleSystems[i];
             if (particleSystem.particleCount > 0)
             {
                 ParticleSystemRenderer component = particleSystem.GetComponent <ParticleSystemRenderer>();
                 if (ParticleEffectUI.m_ShowBounds)
                 {
                     Color color = Handles.color;
                     Handles.color = Color.yellow;
                     Bounds bounds = component.bounds;
                     Handles.DrawWireCube(bounds.center, bounds.size);
                     Handles.color = color;
                 }
                 EditorUtility.SetSelectedRenderState(component, (!ParticleEffectUI.m_ShowWireframe) ? EditorSelectedRenderState.Hidden : EditorSelectedRenderState.Wireframe);
             }
         }
         this.UpdateProperties();
         ModuleUI[] modules = this.m_Modules;
         for (int j = 0; j < modules.Length; j++)
         {
             ModuleUI moduleUI = modules[j];
             if (moduleUI != null && moduleUI.visibleUI && moduleUI.enabled)
             {
                 if (moduleUI.foldout)
                 {
                     moduleUI.OnSceneViewGUI();
                 }
             }
         }
         this.ApplyProperties();
     }
 }
Beispiel #2
0
        public void OnSceneGUI()
        {
            if (!target)
            {
                return;
            }
            SkinnedMeshRenderer renderer = (SkinnedMeshRenderer)target;

            if (renderer.updateWhenOffscreen)
            {
                Bounds  bounds = renderer.bounds;
                Vector3 center = bounds.center;
                Vector3 size   = bounds.size;

                Handles.DrawWireCube(center, size);
            }
            else
            {
                using (new Handles.DrawingScope(renderer.actualRootBone.localToWorldMatrix))
                {
                    Bounds bounds = renderer.localBounds;
                    m_BoundsHandle.center = bounds.center;
                    m_BoundsHandle.size   = bounds.size;

                    // only display interactive handles if edit mode is active
                    m_BoundsHandle.handleColor = EditMode.editMode == EditMode.SceneViewEditMode.Collider && EditMode.IsOwner(this) ?
                                                 m_BoundsHandle.wireframeColor : Color.clear;

                    EditorGUI.BeginChangeCheck();
                    m_BoundsHandle.DrawHandle();
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(renderer, "Resize Bounds");
                        renderer.localBounds = new Bounds(m_BoundsHandle.center, m_BoundsHandle.size);
                    }
                }
            }
        }
        public void OnSceneGUI()
        {
            SkinnedMeshRenderer skinnedMeshRenderer = (SkinnedMeshRenderer)base.target;

            if (skinnedMeshRenderer.updateWhenOffscreen)
            {
                Bounds  bounds = skinnedMeshRenderer.bounds;
                Vector3 center = bounds.center;
                Vector3 size   = bounds.size;
                Handles.DrawWireCube(center, size);
            }
            else
            {
                Bounds  localBounds = skinnedMeshRenderer.localBounds;
                Vector3 center2     = localBounds.center;
                Vector3 size2       = localBounds.size;
                if (this.m_BoxEditor.OnSceneGUI(skinnedMeshRenderer.actualRootBone, Handles.s_BoundingBoxHandleColor, false, ref center2, ref size2))
                {
                    Undo.RecordObject(skinnedMeshRenderer, "Resize Bounds");
                    skinnedMeshRenderer.localBounds = new Bounds(center2, size2);
                }
            }
        }
        public void OnSceneGUI()
        {
            SkinnedMeshRenderer target = (SkinnedMeshRenderer)base.target;

            if (target.updateWhenOffscreen)
            {
                Bounds  bounds = target.bounds;
                Vector3 center = bounds.center;
                Vector3 size   = bounds.size;
                Handles.DrawWireCube(center, size);
            }
            else
            {
                Bounds  localBounds = target.localBounds;
                Vector3 vector3     = localBounds.center;
                Vector3 vector4     = localBounds.size;
                if (this.m_BoxEditor.OnSceneGUI(target.actualRootBone, Handles.s_BoundingBoxHandleColor, false, ref vector3, ref vector4))
                {
                    Undo.RecordObject(target, "Resize Bounds");
                    target.localBounds = new Bounds(vector3, vector4);
                }
            }
        }
Beispiel #5
0
        public void OnSceneGUI()
        {
            if (this.m_Modules == null || this.m_ParticleSystem == null)
            {
                return;
            }
            if (this.m_ParticleSystem.particleCount > 0)
            {
                ParticleSystemRenderer particleSystemRenderer = this.GetParticleSystemRenderer();
                if (ParticleEffectUI.m_ShowBounds)
                {
                    Color color = Handles.color;
                    Handles.color = Color.yellow;
                    Bounds bounds = particleSystemRenderer.bounds;
                    Handles.DrawWireCube(bounds.center, bounds.size);
                    Handles.color = color;
                }
                EditorUtility.SetSelectedWireframeHidden(particleSystemRenderer, !ParticleEffectUI.m_ShowWireframe);
            }
            this.UpdateProperties();
            InitialModuleUI initial = (InitialModuleUI)this.m_Modules[0];

            ModuleUI[] modules = this.m_Modules;
            for (int i = 0; i < modules.Length; i++)
            {
                ModuleUI moduleUI = modules[i];
                if (moduleUI != null && moduleUI.visibleUI && moduleUI.enabled)
                {
                    if (moduleUI.foldout)
                    {
                        moduleUI.OnSceneGUI(this.m_ParticleSystem, initial);
                    }
                }
            }
            this.ApplyProperties();
        }
Beispiel #6
0
 protected override void DrawWireframe()
 {
     Handles.DrawWireCube(center, GetSize());
 }
Beispiel #7
0
        private void OnSceneViewGUI(SceneView sceneView)
        {
            // Bounds
            if (s_PreviewShowBounds)
            {
                var oldCol = Handles.color;
                Handles.color = s_BoundsColor;

                foreach (var obj in targets)
                {
                    if (obj is TrailRenderer tr)
                    {
                        var worldBounds = tr.bounds;
                        Handles.DrawWireCube(worldBounds.center, worldBounds.size);
                    }
                }

                Handles.color = oldCol;
            }

            // Move trail using shape
            if (m_PreviewBackupPosition.HasValue)
            {
                if (target is TrailRenderer tr)
                {
                    if (s_PreviewIsPlaying && !s_PreviewIsPaused)
                    {
                        Tools.hidden = !(EditorToolManager.activeTool is ShapeGizmoTool);

                        float previousPreviewTimePercentage = m_PreviewTimePercentage;
                        float timeStep = Mathf.Min(Time.deltaTime, 0.1f);

                        float moveSpeed = s_PreviewMovementSpeed;
                        if (s_PreviewShape == PreviewShape.Spring)
                        {
                            moveSpeed *= 0.5f;
                        }

                        m_PreviewTimePercentage += (timeStep * moveSpeed * s_PreviewTimeScale);
                        m_PreviewTimePercentage %= 1.0f;

                        tr.previewTimeScale = s_PreviewTimeScale;

                        var       transform      = tr.transform;
                        Matrix4x4 localTransform = Matrix4x4.TRS(Vector3.zero, transform.localRotation, transform.localScale);

                        switch (s_PreviewShape)
                        {
                        case PreviewShape.Circle:
                            transform.localPosition = m_PreviewBackupPosition.Value + localTransform.MultiplyPoint(new Vector3(Mathf.Sin(m_PreviewTimePercentage * Mathf.PI * 2.0f), Mathf.Cos(m_PreviewTimePercentage * Mathf.PI * 2.0f), 0.0f) * s_PreviewShapeSize);
                            break;

                        case PreviewShape.Square:
                            if (m_PreviewTimePercentage < 0.25f)
                            {
                                transform.localPosition = m_PreviewBackupPosition.Value + localTransform.MultiplyPoint(new Vector3(Mathf.Lerp(-1.0f, 1.0f, m_PreviewTimePercentage * 4.0f), -1.0f, 0.0f) * s_PreviewShapeSize);
                            }
                            else if (m_PreviewTimePercentage < 0.5f)
                            {
                                transform.localPosition = m_PreviewBackupPosition.Value + localTransform.MultiplyPoint(new Vector3(1.0f, Mathf.Lerp(-1.0f, 1.0f, (m_PreviewTimePercentage - 0.25f) * 4.0f), 0.0f) * s_PreviewShapeSize);
                            }
                            else if (m_PreviewTimePercentage < 0.75f)
                            {
                                transform.localPosition = m_PreviewBackupPosition.Value + localTransform.MultiplyPoint(new Vector3(Mathf.Lerp(1.0f, -1.0f, (m_PreviewTimePercentage - 0.5f) * 4.0f), 1.0f, 0.0f) * s_PreviewShapeSize);
                            }
                            else
                            {
                                transform.localPosition = m_PreviewBackupPosition.Value + localTransform.MultiplyPoint(new Vector3(-1.0f, Mathf.Lerp(1.0f, -1.0f, (m_PreviewTimePercentage - 0.75f) * 4.0f), 0.0f) * s_PreviewShapeSize);
                            }
                            break;

                        case PreviewShape.Line:
                            transform.localPosition = m_PreviewBackupPosition.Value + localTransform.MultiplyPoint(new Vector3(Mathf.Lerp(-1.0f, 1.0f, m_PreviewTimePercentage), 0.0f, 0.0f) * s_PreviewShapeSize);
                            break;

                        case PreviewShape.SineWave:
                            transform.localPosition = m_PreviewBackupPosition.Value + localTransform.MultiplyPoint(new Vector3(Mathf.Lerp(-1.0f, 1.0f, m_PreviewTimePercentage), Mathf.Sin(m_PreviewTimePercentage * Mathf.PI * 2.0f * k_SineWaveRepeat) * k_SineWaveHeightMultiplier, 0.0f) * s_PreviewShapeSize);
                            break;

                        case PreviewShape.Spring:
                            transform.localPosition = m_PreviewBackupPosition.Value + localTransform.MultiplyPoint(new Vector3(Mathf.Sin(m_PreviewTimePercentage * Mathf.PI * 2.0f * k_SpringRotations), Mathf.Cos(m_PreviewTimePercentage * Mathf.PI * 2.0f * k_SpringRotations), Mathf.Lerp(-0.5f, 0.5f, m_PreviewTimePercentage) * k_SpringRotations) * s_PreviewShapeSize);
                            break;
                        }

                        // Clear non-looping shapes when they repeat
                        if (previousPreviewTimePercentage > m_PreviewTimePercentage)
                        {
                            if (s_PreviewShape == PreviewShape.Line || s_PreviewShape == PreviewShape.SineWave || s_PreviewShape == PreviewShape.Spring)
                            {
                                tr.Clear();
                            }
                        }

                        // Clear the trail when a preview starts
                        if (m_PreviewIsFirstMove)
                        {
                            tr.Clear();
                            m_PreviewIsFirstMove = false;
                        }
                    }
                    else if (s_PreviewIsPaused)
                    {
                        tr.previewTimeScale = 0.0f;
                    }
                }
            }
        }