Ejemplo n.º 1
0
        public void OnGUI()
        {
            // Commenting out until we revisit the alternate renderer(s) - MAT (10/17/16)
//            m_RendererIndex = EditorGUIBinding.Popup(m_RendererIndex, m_RendererOptions, RendererChange);
            using (new EditorGUILayout.VerticalScope())
            {
                EditorGUILayout.LabelField("Data set options", EditorStyles.boldLabel);
                AnalyticsListGroup.ListGroup(m_ViewModel.heatmapOptions,
                                             m_ViewModel.heatmapOptionLabels, OptionsChange);
            }

            // PARTICLE SIZE/SHAPE
            using (new EditorGUILayout.VerticalScope())
            {
                EditorGUILayout.LabelField("Render options", EditorStyles.boldLabel);

                if (m_GameObject == null)
                {
                    EditorGUILayout.LabelField("No heatmap. Can't show gradient.", EditorStyles.boldLabel);
                }
                else if (m_ColorGradient != null)
                {
                    EditorGUI.BeginChangeCheck();
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        EditorGUILayout.PropertyField(m_ColorGradient, false);
                        m_ViewModel.heatmapInFront = EditorGUILayout.Toggle("Always in front", m_ViewModel.heatmapInFront);
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_SerializedGradient.ApplyModifiedProperties();
                    }
                }

                m_ViewModel.particleSize = EditorGUILayout.FloatField(m_ParticleSizeContent, m_ViewModel.particleSize);

                using (new EditorGUILayout.HorizontalScope())
                {
                    float lw = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 40f;
                    m_ViewModel.particleShape   = EditorGUILayout.Popup(m_ParticleShapeContent, m_ViewModel.particleShape, m_ParticleShapeOptions);


                    EditorGUIUtility.labelWidth = 60f;
                    if (m_ViewModel.particleShape > 2)
                    {
                        m_ViewModel.particleDirection = EditorGUILayout.Popup(m_ParticleDirectionContent, m_ViewModel.particleDirection, m_ParticleDirectionOptions);
                    }

                    if (m_ViewModel.particleShape == 1 || m_ViewModel.particleShape == 2)
                    {
                        m_ViewModel.particleProjection = EditorGUILayout.Popup(m_ParticleProjectionContent, m_ViewModel.particleProjection, m_ParticleProjectionOptions);
                    }
                    EditorGUIUtility.labelWidth = lw;
                }
            }

            // POSITION MASKING
            using (new EditorGUILayout.VerticalScope("box"))
            {
                EditorGUILayout.LabelField("Filtering", EditorStyles.boldLabel);
                using (new EditorGUILayout.HorizontalScope())
                {
                    float lw = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 10f;
                    EditorGUILayout.LabelField("Follow");
                    m_ViewModel.maskFollowType  = GUILayout.Toolbar(m_ViewModel.maskFollowType, m_FollowOptions);
                    EditorGUIUtility.labelWidth = lw;
                }
                EditorGUILayout.Space();
                EditorGUI.BeginDisabledGroup(m_ViewModel.maskFollowType != k_NoFollow);
                m_MaskRadiusSource = EditorGUILayout.Vector3Field("", m_MaskRadiusSource);
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.Space();

                GUIContent[] maskOptionContent = new GUIContent[] { m_MaskOptionContentSlice, m_MaskOptionContentRadius };
                m_ViewModel.maskType = GUILayout.Toolbar(m_ViewModel.maskType, maskOptionContent);

                if (m_ViewModel.maskType == 1)
                {
                    m_ViewModel.maskRadius = EditorGUILayout.FloatField(m_MaskRadiusContent, m_ViewModel.maskRadius);
                }
                else
                {
                    RenderMinMaxSlider("x", ref m_LowX, ref m_HighX, k_LowXKey, k_HighXKey, m_LowSpace.x, m_HighSpace.x);
                    RenderMinMaxSlider("y", ref m_LowY, ref m_HighY, k_LowYKey, k_HighYKey, m_LowSpace.y, m_HighSpace.y);
                    RenderMinMaxSlider("z", ref m_LowZ, ref m_HighZ, k_LowZKey, k_HighZKey, m_LowSpace.z, m_HighSpace.z);
                }
            }

            // TIME WINDOW
            var oldStartTime = m_StartTime;
            var oldEndTime   = m_EndTime;

            using (new EditorGUILayout.VerticalScope("box"))
            {
                EditorGUILayout.LabelField("Time", EditorStyles.boldLabel);
                RenderMinMaxSlider("t", ref m_StartTime, ref m_EndTime, k_StartTimeKey, k_EndTimeKey, 0f, m_MaxTime);
                var oldPlaySpeed = m_PlaySpeed;
                m_PlaySpeed = EditorGUILayout.FloatField(m_PlaySpeedContent, m_PlaySpeed);
                if (oldPlaySpeed != m_PlaySpeed)
                {
                    EditorPrefs.SetFloat(k_PlaySpeedKey, m_PlaySpeed);
                }
                using (new EditorGUILayout.HorizontalScope())
                {
                    if (GUILayout.Button(m_RestartContent))
                    {
                        Restart();
                        m_IsPlaying = false;
                    }

                    GUIContent playButtonContent = m_IsPlaying ? m_PauseContent : m_PlayContent;
                    if (GUILayout.Button(playButtonContent))
                    {
                        if (m_StartTime < m_MaxTime && m_EndTime == m_MaxTime)
                        {
                            Restart();
                        }
                        m_IsPlaying = !m_IsPlaying;
                    }
                }
            }
            bool forceTime = false;

            if (oldStartTime != m_StartTime)
            {
                forceTime = true;
            }
            if (oldEndTime != m_EndTime)
            {
                forceTime = true;
            }

            // Loop Playback
            bool oldLoop = m_Loop;

            m_Loop = EditorGUILayout.Toggle(m_LoopTextContent, m_Loop);
            if (oldLoop != m_Loop)
            {
                EditorPrefs.SetBool(k_LoopKey, m_Loop);
            }

            Update(forceTime);

            // REPORTING AND TIPS
            EditorGUILayout.LabelField(m_TipsTextContent);
            bool oldTips = m_Tips;

            m_Tips = EditorGUILayout.Toggle(m_TipsContent, m_Tips);
            if (oldTips != m_Tips)
            {
                EditorPrefs.SetBool(k_ShowTipsKey, m_Tips);
            }

            if (Event.current.type == EventType.Layout)
            {
                if (m_GameObject != null && m_GameObject.GetComponent <IHeatmapRenderer>() != null)
                {
                    int total   = m_GameObject.GetComponent <IHeatmapRenderer>().totalPoints;
                    int current = m_GameObject.GetComponent <IHeatmapRenderer>().currentPoints;
                    m_TipsTextContent = new GUIContent("Points (displayed/total): " + current + " / " + total);
                }

                // PASS VALUES TO RENDERER
                if (m_GameObject != null)
                {
                    IHeatmapRenderer r = m_GameObject.GetComponent <IHeatmapRenderer>() as IHeatmapRenderer;
                    r.UpdateGradient(SafeGradientValue(m_ColorGradient));
                    r.pointSize    = m_ViewModel.particleSize;
                    r.activateTips = m_Tips;
                    r.UpdateCameraPosition(m_MaskRadiusSource);
                    r.heatmapInFront = m_ViewModel.heatmapInFront;
                    if (m_ViewModel.maskType == 1)
                    {
                        r.UpdateRenderMask(m_ViewModel.maskRadius);
                    }
                    else
                    {
                        r.UpdateRenderMask(m_LowX, m_HighX, m_LowY, m_HighY, m_LowZ, m_HighZ);
                    }
                    r.UpdateProjection(m_ParticleProjectionIds[m_ViewModel.particleProjection]);
                    r.UpdateRenderStyle(m_ParticleShapeIds[m_ViewModel.particleShape], m_ParticleDirectionIds[m_ViewModel.particleDirection]);
                }
            }
        }
Ejemplo n.º 2
0
        public void OnGUI()
        {
            using (new EditorGUILayout.VerticalScope("box"))
            {
                if (m_GameObject == null)
                {
                    EditorGUILayout.LabelField("No heatmap. Can't show gradient.", EditorStyles.boldLabel);
                }
                else if (m_ColorGradient != null)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(m_ColorGradient, false);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_SerializedGradient.ApplyModifiedProperties();
                    }
                }
            }

            // PARTICLE SIZE/SHAPE
            using (new EditorGUILayout.VerticalScope("box"))
            {
                EditorGUILayout.LabelField("Particle", EditorStyles.boldLabel);
                var oldParticleSize = m_ParticleSize;
                m_ParticleSize = EditorGUILayout.FloatField(m_ParticleSizeContent, m_ParticleSize);
                m_ParticleSize = Mathf.Max(0.05f, m_ParticleSize);
                if (oldParticleSize != m_ParticleSize)
                {
                    EditorPrefs.SetFloat(k_ParticleSizeKey, m_ParticleSize);
                }

                var oldParticleShapeIndex = m_ParticleShapeIndex;
                m_ParticleShapeIndex = EditorGUILayout.Popup(m_ParticleShapeContent, m_ParticleShapeIndex, m_ParticleShapeOptions);
                if (oldParticleShapeIndex != m_ParticleShapeIndex)
                {
                    EditorPrefs.SetInt(k_ParticleShapeKey, m_ParticleShapeIndex);
                }

                if (m_ParticleShapeIndex > 2)
                {
                    var oldParticleDirectionIndex = m_ParticleDirectionIndex;
                    m_ParticleDirectionIndex = EditorGUILayout.Popup(m_ParticleDirectionContent, m_ParticleDirectionIndex, m_ParticleDirectionOptions);
                    if (oldParticleDirectionIndex != m_ParticleDirectionIndex)
                    {
                        EditorPrefs.SetInt(k_ParticleDirectionKey, m_ParticleDirectionIndex);
                    }
                }
                // POSITION MASKING
                EditorGUILayout.LabelField("Masking (x/y/z)");
                RenderMinMaxSlider(ref m_LowX, ref m_HighX, k_LowXKey, k_HighXKey, m_LowSpace.x, m_HighSpace.x);
                RenderMinMaxSlider(ref m_LowY, ref m_HighY, k_LowYKey, k_HighYKey, m_LowSpace.y, m_HighSpace.y);
                RenderMinMaxSlider(ref m_LowZ, ref m_HighZ, k_LowZKey, k_HighZKey, m_LowSpace.z, m_HighSpace.z);
            }

            // TIME WINDOW
            var oldStartTime = m_StartTime;
            var oldEndTime   = m_EndTime;

            using (new EditorGUILayout.VerticalScope("box"))
            {
                EditorGUILayout.LabelField("Time", EditorStyles.boldLabel);
                RenderMinMaxSlider(ref m_StartTime, ref m_EndTime, k_StartTimeKey, k_EndTimeKey, 0f, m_MaxTime);
                var oldPlaySpeed = m_PlaySpeed;
                m_PlaySpeed = EditorGUILayout.FloatField(m_PlaySpeedContent, m_PlaySpeed);
                if (oldPlaySpeed != m_PlaySpeed)
                {
                    EditorPrefs.SetFloat(k_PlaySpeedKey, m_PlaySpeed);
                }
                using (new EditorGUILayout.HorizontalScope())
                {
                    if (GUILayout.Button(m_RestartContent))
                    {
                        Restart();
                        m_IsPlaying = false;
                    }

                    GUIContent playButtonContent = m_IsPlaying ? m_PauseContent : m_PlayContent;
                    if (GUILayout.Button(playButtonContent))
                    {
                        if (m_StartTime < m_MaxTime && m_EndTime == m_MaxTime)
                        {
                            Restart();
                        }
                        m_IsPlaying = !m_IsPlaying;
                    }
                }
            }
            bool forceTime = false;

            if (oldStartTime != m_StartTime)
            {
                forceTime = true;
            }
            if (oldEndTime != m_EndTime)
            {
                forceTime = true;
            }
            Update(forceTime);

            // REPORTING AND TIPS
            EditorGUILayout.LabelField(m_TipsTextContent);
            bool oldTips = m_Tips;

            m_Tips = EditorGUILayout.Toggle(m_TipsContent, m_Tips);
            if (oldTips != m_Tips)
            {
                EditorPrefs.SetBool(k_ShowTipsKey, m_Tips);
            }

            if (Event.current.type == EventType.Layout)
            {
                if (m_GameObject != null && m_GameObject.GetComponent <IHeatmapRenderer>() != null)
                {
                    int total   = m_GameObject.GetComponent <IHeatmapRenderer>().totalPoints;
                    int current = m_GameObject.GetComponent <IHeatmapRenderer>().currentPoints;
                    m_TipsTextContent = new GUIContent("Points (displayed/total): " + current + " / " + total);
                }

                // PASS VALUES TO RENDERER
                if (m_GameObject != null)
                {
                    IHeatmapRenderer r = m_GameObject.GetComponent <IHeatmapRenderer>() as IHeatmapRenderer;
                    r.UpdateGradient(SafeGradientValue(m_ColorGradient));
                    r.pointSize    = m_ParticleSize;
                    r.activateTips = m_Tips;
                    r.UpdateRenderMask(m_LowX, m_HighX, m_LowY, m_HighY, m_LowZ, m_HighZ);
                    r.UpdateRenderStyle(m_ParticleShapeIds[m_ParticleShapeIndex], m_ParticleDirectionIds[m_ParticleDirectionIndex]);
                }
            }
        }