コード例 #1
0
 public void Update(bool forceUpdate = false)
 {
     if (m_GameObject != null)
     {
         float oldStartTime = m_StartTime;
         float oldEndTime   = m_EndTime;
         UpdateTime();
         if (forceUpdate || oldStartTime != m_StartTime || oldEndTime != m_EndTime)
         {
             IHeatmapRenderer r = m_GameObject.GetComponent <IHeatmapRenderer>() as IHeatmapRenderer;
             if (r != null)
             {
                 r.UpdateTimeLimits(m_StartTime, m_EndTime);
                 m_Heatmapper.Repaint();
             }
         }
     }
 }
コード例 #2
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]);
                }
            }
        }
コード例 #3
0
        public void OnGUI()
        {
            // COLORS
            EditorGUILayout.BeginVertical("box");
            m_HighDensityColor   = SetAndSaveColor(new GUIContent("High Color", "Color for high density data"), k_HighColorDensityKey, m_HighDensityColor);
            m_MediumDensityColor = SetAndSaveColor(new GUIContent("Medium Color", "Color for medium density data"), k_MediumColorDensityKey, m_MediumDensityColor);
            m_LowDensityColor    = SetAndSaveColor(new GUIContent("Low Color", "Color for low density data"), k_LowColorDensityKey, m_LowDensityColor);

            // THRESHOLDS
            var oldLowThreshold  = m_LowThreshold;
            var oldHighThreshold = m_HighThreshold;

            m_LowThreshold  = EditorGUILayout.FloatField(new GUIContent("Low Threshold", "Normalized threshold between low-density and medium-density data"), m_LowThreshold);
            m_HighThreshold = EditorGUILayout.FloatField(new GUIContent("High Threshold", "Normalized threshold between medium-density and high-density data"), m_HighThreshold);

            m_LowThreshold  = Mathf.Min(m_LowThreshold, m_HighThreshold);
            m_HighThreshold = Mathf.Max(m_LowThreshold, m_HighThreshold);

            EditorGUILayout.MinMaxSlider(ref m_LowThreshold, ref m_HighThreshold, 0f, 1f);
            if (oldLowThreshold != m_LowThreshold)
            {
                EditorPrefs.SetFloat(k_LowThresholdKey, m_LowThreshold);
            }
            if (oldHighThreshold != m_HighThreshold)
            {
                EditorPrefs.SetFloat(k_HighThresholdKey, m_HighThreshold);
            }
            EditorGUILayout.EndVertical();


            // TIME WINDOW
            EditorGUILayout.BeginVertical("box");
            var oldStartTime = m_StartTime;
            var oldEndTime   = m_EndTime;

            m_StartTime = EditorGUILayout.FloatField(new GUIContent("Start Time", "Show only data after this time"), m_StartTime);
            m_EndTime   = EditorGUILayout.FloatField(new GUIContent("End Time", "Show only data before this time"), m_EndTime);

            m_StartTime = Mathf.Min(m_StartTime, m_EndTime);
            m_EndTime   = Mathf.Max(m_StartTime, m_EndTime);

            EditorGUILayout.MinMaxSlider(ref m_StartTime, ref m_EndTime, 0f, m_MaxTime);
            if (GUILayout.Button(new GUIContent("Max Time", "Set time to maximum extents")))
            {
                m_StartTime = 0;
                m_EndTime   = m_MaxTime;
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("box");

            var oldPlaySpeed = m_PlaySpeed;

            m_PlaySpeed = EditorGUILayout.FloatField(new GUIContent("Play Speed", "Speed at which playback occurs"), m_PlaySpeed);

            if (oldPlaySpeed != m_PlaySpeed)
            {
                EditorPrefs.SetFloat(k_PlaySpeedKey, m_PlaySpeed);
            }

            EditorGUILayout.BeginHorizontal();
            GUIContent restartContent = new GUIContent("<<", "Back to Start");

            if (GUILayout.Button(restartContent))
            {
                Restart();
                m_IsPlaying = false;
            }

            string     playTip     = m_IsPlaying ? "Pause" : "Play";
            string     playText    = m_IsPlaying ? "||" : ">";
            GUIContent playContent = new GUIContent(playText, playTip);

            if (GUILayout.Button(playContent))
            {
                if (m_EndTime == m_MaxTime)
                {
                    Restart();
                }
                m_IsPlaying = !m_IsPlaying;
            }
            EditorGUILayout.EndHorizontal();

            bool forceTime = false;

            if (oldStartTime != m_StartTime)
            {
                forceTime = true;
                EditorPrefs.SetFloat(k_StartTimeKey, m_StartTime);
            }
            if (oldEndTime != m_EndTime)
            {
                forceTime = true;
                EditorPrefs.SetFloat(k_EndTimeKey, m_EndTime);
            }

            Update(forceTime);

            EditorGUILayout.EndVertical();

            // PARTICLE SIZE/SHAPE
            EditorGUILayout.BeginVertical("box");
            var oldParticleSize = m_ParticleSize;

            m_ParticleSize = EditorGUILayout.FloatField(new GUIContent("Particle Size", "The display size of an individual data point"), 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(new GUIContent("Particle Shape", "The display shape of an individual data point"), m_ParticleShapeIndex, m_ParticleShapeOptions);
            if (oldParticleShapeIndex != m_ParticleShapeIndex)
            {
                EditorPrefs.SetInt(k_ParticleShapeKey, m_ParticleShapeIndex);
            }

            if (m_ParticleShapeIndex > 0)
            {
                var oldParticleDirectionIndex = m_ParticleDirectionIndex;
                m_ParticleDirectionIndex = EditorGUILayout.Popup(new GUIContent("Billboard plane", "For 2D shapes, the facing direction of an individual data point"), m_ParticleDirectionIndex, m_ParticleDirectionOptions);
                if (oldParticleDirectionIndex != m_ParticleDirectionIndex)
                {
                    EditorPrefs.SetInt(k_ParticleDirectionKey, m_ParticleDirectionIndex);
                }
            }
            EditorGUILayout.EndVertical();

            if (m_GameObject != null && m_GameObject.GetComponent <IHeatmapRenderer>() != null)
            {
                int total   = m_GameObject.GetComponent <IHeatmapRenderer>().totalPoints;
                int current = m_GameObject.GetComponent <IHeatmapRenderer>().currentPoints;
                GUILayout.Label("Points in current set: " + total);
                GUILayout.Label("Points currently displayed: " + current);
            }

            // PASS VALUES TO RENDERER
            if (m_GameObject != null)
            {
                IHeatmapRenderer r = m_GameObject.GetComponent <IHeatmapRenderer>() as IHeatmapRenderer;
                r.UpdateColors(new Color[] { m_LowDensityColor, m_MediumDensityColor, m_HighDensityColor });
                r.UpdateThresholds(new float[] { m_LowThreshold, m_HighThreshold });
                r.pointSize = m_ParticleSize;
                r.UpdateRenderStyle(m_ParticleShapeIds[m_ParticleShapeIndex], m_ParticleDirectionIds[m_ParticleDirectionIndex]);
            }
        }
コード例 #4
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]);
                }
            }
        }