GetCustomFilterChannelCount() private method

private GetCustomFilterChannelCount ( MonoBehaviour behaviour ) : int
behaviour UnityEngine.MonoBehaviour
return int
Exemplo n.º 1
0
        public void DrawAudioFilterGUI(MonoBehaviour behaviour)
        {
            int customFilterChannelCount = AudioUtil.GetCustomFilterChannelCount(behaviour);

            if (customFilterChannelCount > 0)
            {
                if (this.dataOut == null)
                {
                    this.dataOut = new EditorGUI.VUMeter.SmoothingData[customFilterChannelCount];
                }
                double num2 = ((double)AudioUtil.GetCustomFilterProcessTime(behaviour)) / 1000000.0;
                float  r    = ((float)num2) / ((((float)AudioSettings.outputSampleRate) / 1024f) / ((float)customFilterChannelCount));
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(13f);
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                EditorGUILayout.Space();
                for (int i = 0; i < customFilterChannelCount; i++)
                {
                    GUILayoutOption[] optionArray1 = new GUILayoutOption[] { GUILayout.MinWidth(50f), GUILayout.Height(5f) };
                    EditorGUILayout.VUMeterHorizontal(AudioUtil.GetCustomFilterMaxOut(behaviour, i), ref this.dataOut[i], optionArray1);
                }
                GUILayout.EndVertical();
                Color color = GUI.color;
                GUI.color = new Color(r, 1f - r, 0f, 1f);
                GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MinWidth(40f), GUILayout.Height(20f) };
                GUILayout.Box($"{num2:00.00}ms", options);
                GUI.color = color;
                GUILayout.EndHorizontal();
                EditorGUILayout.Space();
                GUIView.current.Repaint();
            }
        }
Exemplo n.º 2
0
        public void DrawAudioFilterGUI(MonoBehaviour behaviour)
        {
            int channelCount = AudioUtil.GetCustomFilterChannelCount(behaviour);

            if (channelCount > 0)
            {
                if (dataOut == null)
                {
                    dataOut = new EditorGUI.VUMeter.SmoothingData[channelCount];
                }

                double ms    = (double)AudioUtil.GetCustomFilterProcessTime(behaviour) / 1000000.0; // ms
                float  limit = (float)ms / ((float)AudioSettings.outputSampleRate / 1024.0f / (float)channelCount);

                GUILayout.BeginHorizontal();
                GUILayout.Space(13);
                GUILayout.BeginVertical();
                EditorGUILayout.Space();
                for (int c = 0; c < channelCount; ++c)
                {
                    EditorGUILayout.VUMeterHorizontal(AudioUtil.GetCustomFilterMaxOut(behaviour, c), ref dataOut[c], GUILayout.MinWidth(50), GUILayout.Height(5));
                }
                GUILayout.EndVertical();
                Color old = GUI.color;
                GUI.color = new Color(limit, 1.0f - limit, 0.0f, 1.0f);
                GUILayout.Box(UnityString.Format("{0:00.00}ms", ms), GUILayout.MinWidth(40), GUILayout.Height(20));
                GUI.color = old;

                GUILayout.EndHorizontal();
                EditorGUILayout.Space();

                // force repaint
                GUIView.current.Repaint();
            }
        }
Exemplo n.º 3
0
        internal override bool GetOptimizedGUIBlock(bool isDirty, bool isVisible, out OptimizedGUIBlock block, out float height)
        {
            bool optimizedGUIBlockImplementation = base.GetOptimizedGUIBlockImplementation(isDirty, isVisible, out block, out height);
            bool result;

            if (base.target is MonoBehaviour)
            {
                if (AudioUtil.HasAudioCallback(base.target as MonoBehaviour) && AudioUtil.GetCustomFilterChannelCount(base.target as MonoBehaviour) > 0)
                {
                    result = false;
                    return(result);
                }
            }
            result = (!this.IsMissingMonoBehaviourTarget() && optimizedGUIBlockImplementation);
            return(result);
        }
Exemplo n.º 4
0
 public override void OnInspectorGUI()
 {
     if (!this.IsMissingMonoBehaviourTarget() || !this.MissingMonoBehaviourGUI())
     {
         base.OnInspectorGUI();
         if (base.target is MonoBehaviour)
         {
             if (AudioUtil.HasAudioCallback(base.target as MonoBehaviour) && AudioUtil.GetCustomFilterChannelCount(base.target as MonoBehaviour) > 0)
             {
                 if (this.m_AudioFilterGUI == null)
                 {
                     this.m_AudioFilterGUI = new AudioFilterGUI();
                 }
                 this.m_AudioFilterGUI.DrawAudioFilterGUI(base.target as MonoBehaviour);
             }
         }
     }
 }
Exemplo n.º 5
0
        internal bool DoDrawDefaultInspector()
        {
            bool res;
            using (new UnityEditor.Localization.Editor.LocalizationGroup(target))
            {
                res = DoDrawDefaultInspector(serializedObject);

                var behaviour = target as MonoBehaviour;
                if (behaviour == null || !AudioUtil.HasAudioCallback(behaviour) || AudioUtil.GetCustomFilterChannelCount(behaviour) <= 0)
                    return res;

                // If we have an OnAudioFilterRead callback, draw vu meter
                if (m_AudioFilterGUI == null)
                    m_AudioFilterGUI = new AudioFilterGUI();
                m_AudioFilterGUI.DrawAudioFilterGUI(behaviour);
            }
            return res;
        }
        internal override bool GetOptimizedGUIBlock(bool isDirty, bool isVisible, out OptimizedGUIBlock block, out float height)
        {
            bool result = GetOptimizedGUIBlockImplementation(isDirty, isVisible, out block, out height);

            // Don't use optimizedGUI for audio filters
            if (target is MonoBehaviour)
            {
                if (AudioUtil.HasAudioCallback(target as MonoBehaviour) && AudioUtil.GetCustomFilterChannelCount(target as MonoBehaviour) > 0)
                {
                    return(false);
                }
            }

            if (IsMissingMonoBehaviourTarget())
            {
                return(false);
            }

            return(result);
        }
        public override void OnInspectorGUI()
        {
            if (IsMissingMonoBehaviourTarget() && MissingMonoBehaviourGUI())
            {
                return;
            }

            base.OnInspectorGUI();

            if (target is MonoBehaviour)
            {
                // Does this have a AudioRead callback?
                if (AudioUtil.HasAudioCallback(target as MonoBehaviour) && AudioUtil.GetCustomFilterChannelCount(target as MonoBehaviour) > 0)
                {
                    if (m_AudioFilterGUI == null)
                    {
                        m_AudioFilterGUI = new AudioFilterGUI();
                    }
                    m_AudioFilterGUI.DrawAudioFilterGUI(target as MonoBehaviour);
                }
            }
        }
Exemplo n.º 8
0
        public void DrawAudioFilterGUI(MonoBehaviour behaviour)
        {
            int filterChannelCount = AudioUtil.GetCustomFilterChannelCount(behaviour);

            if (filterChannelCount <= 0)
            {
                return;
            }
            if (this.dataOut == null)
            {
                this.dataOut = new EditorGUI.VUMeter.SmoothingData[filterChannelCount];
            }
            double num = (double)AudioUtil.GetCustomFilterProcessTime(behaviour) / 1000000.0;
            float  r   = (float)num / ((float)AudioSettings.outputSampleRate / 1024f / (float)filterChannelCount);

            GUILayout.BeginHorizontal();
            GUILayout.Space(13f);
            GUILayout.BeginVertical();
            EditorGUILayout.Space();
            for (int channel = 0; channel < filterChannelCount; ++channel)
            {
                EditorGUILayout.VUMeterHorizontal(AudioUtil.GetCustomFilterMaxOut(behaviour, channel), ref this.dataOut[channel], GUILayout.MinWidth(50f), GUILayout.Height(5f));
            }
            GUILayout.EndVertical();
            Color color = GUI.color;

            GUI.color = new Color(r, 1f - r, 0.0f, 1f);
            GUILayout.Box(string.Format("{0:00.00}ms", (object)num), new GUILayoutOption[2]
            {
                GUILayout.MinWidth(40f),
                GUILayout.Height(20f)
            });
            GUI.color = color;
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();
            GUIView.current.Repaint();
        }
Exemplo n.º 9
0
        public override void OnInspectorGUI()
        {
            if (ObjectIsMonoBehaviourOrScriptableObject(target) && MissingMonoBehaviourGUI())
            {
                return;
            }

            base.OnInspectorGUI();

            var behaviour = target as MonoBehaviour;

            if (behaviour != null)
            {
                // Does this have a AudioRead callback?
                if (AudioUtil.HasAudioCallback(behaviour) && AudioUtil.GetCustomFilterChannelCount(behaviour) > 0)
                {
                    if (m_AudioFilterGUI == null)
                    {
                        m_AudioFilterGUI = new AudioFilterGUI();
                    }
                    m_AudioFilterGUI.DrawAudioFilterGUI(behaviour);
                }
            }
        }
Exemplo n.º 10
0
        internal override bool GetOptimizedGUIBlock(bool isDirty, bool isVisible, out float height)
        {
            height = -1;

            // Don't use optimizedGUI for audio filters
            var behaviour = target as MonoBehaviour;

            if (behaviour != null && AudioUtil.HasAudioCallback(behaviour) && AudioUtil.GetCustomFilterChannelCount(behaviour) > 0)
            {
                return(false);
            }

            if (ObjectIsMonoBehaviourOrScriptableObject(target))
            {
                return(false);
            }

            if (isDirty)
            {
                ResetOptimizedBlock();
            }

            if (!isVisible)
            {
                height = 0;
                return(true);
            }

            // Return cached result if any.
            if (m_OptimizedBlockState != OptimizedBlockState.CheckOptimizedBlock)
            {
                if (m_OptimizedBlockState == OptimizedBlockState.NoOptimizedBlock)
                {
                    return(false);
                }
                height = m_LastHeight;
                return(true);
            }

            // Update serialized object representation
            if (m_SerializedObject == null)
            {
                m_SerializedObject = new SerializedObject(targets, m_Context)
                {
                    inspectorMode = inspectorMode
                }
            }
            ;
            else
            {
                m_SerializedObject.Update();
                m_SerializedObject.inspectorMode = inspectorMode;
            }

            height = 0;
            SerializedProperty property = m_SerializedObject.GetIterator();
            bool childrenAreExpanded    = true;

            while (property.NextVisible(childrenAreExpanded))
            {
                var handler = ScriptAttributeUtility.GetHandler(property);
                height += handler.GetHeight(property, null, false) + EditorGUI.kControlVerticalSpacing;

                childrenAreExpanded = property.isExpanded && EditorGUI.HasVisibleChildFields(property);
            }

            m_LastHeight          = height;
            m_OptimizedBlockState = OptimizedBlockState.HasOptimizedBlock;

            return(true);
        }
Exemplo n.º 11
0
        internal override bool GetOptimizedGUIBlock(bool isDirty, bool isVisible, out OptimizedGUIBlock block, out float height)
        {
            bool optimizedGUIBlockImplementation = base.GetOptimizedGUIBlockImplementation(isDirty, isVisible, out block, out height);

            return((!(this.target is MonoBehaviour) || !AudioUtil.HaveAudioCallback(this.target as MonoBehaviour) || AudioUtil.GetCustomFilterChannelCount(this.target as MonoBehaviour) <= 0) && !this.IsMissingMonoBehaviourTarget() && optimizedGUIBlockImplementation);
        }
Exemplo n.º 12
0
        internal override bool GetOptimizedGUIBlock(bool isDirty, bool isVisible, out OptimizedGUIBlock block, out float height)
        {
            bool flag = base.GetOptimizedGUIBlockImplementation(isDirty, isVisible, out block, out height);

            if ((base.target is MonoBehaviour) && (AudioUtil.HaveAudioCallback(base.target as MonoBehaviour) && (AudioUtil.GetCustomFilterChannelCount(base.target as MonoBehaviour) > 0)))
            {
                return(false);
            }
            if (this.IsMissingMonoBehaviourTarget())
            {
                return(false);
            }
            return(flag);
        }
        internal override bool GetOptimizedGUIBlock(bool isDirty, bool isVisible, out OptimizedGUIBlock block, out float height)
        {
            block = null; height = -1;

            // Don't use optimizedGUI for audio filters
            var behaviour = target as MonoBehaviour;

            if (behaviour != null && AudioUtil.HasAudioCallback(behaviour) && AudioUtil.GetCustomFilterChannelCount(behaviour) > 0)
            {
                return(false);
            }

            if (IsMissingMonoBehaviourTarget())
            {
                return(false);
            }

            if (isDirty && m_OptimizedBlock != null)
            {
                ResetOptimizedBlock();
            }

            if (!isVisible)
            {
                if (m_OptimizedBlock == null)
                {
                    m_OptimizedBlock = new OptimizedGUIBlock();
                }

                height = 0;
                block  = m_OptimizedBlock;
                return(true);
            }

            // Return cached result if any.
            if (m_OptimizedBlockState != OptimizedBlockState.CheckOptimizedBlock)
            {
                if (m_OptimizedBlockState == OptimizedBlockState.NoOptimizedBlock)
                {
                    return(false);
                }
                height = m_LastHeight;
                block  = m_LastOptimizedBlock;
                return(true);
            }

            // Update serialized object representation
            if (m_SerializedObject == null)
            {
                m_SerializedObject = new SerializedObject(targets, m_Context)
                {
                    inspectorMode = m_InspectorMode
                }
            }
            ;
            else
            {
                m_SerializedObject.Update();
                m_SerializedObject.inspectorMode = m_InspectorMode;
            }

            height = 0;
            SerializedProperty property = m_SerializedObject.GetIterator();

            while (property.NextVisible(height <= 0))
            {
                var handler = ScriptAttributeUtility.GetHandler(property);
                if (!handler.CanCacheInspectorGUI(property))
                {
                    return(ResetOptimizedBlock(OptimizedBlockState.NoOptimizedBlock));
                }

                // Allocate height for control plus spacing below it
                height += handler.GetHeight(property, null, true) + EditorGUI.kControlVerticalSpacing;
            }

            // Allocate height for spacing above first control
            if (height > 0)
            {
                height += EditorGUI.kControlVerticalSpacing;
            }

            if (m_OptimizedBlock == null)
            {
                m_OptimizedBlock = new OptimizedGUIBlock();
            }

            m_LastHeight          = height;
            m_LastOptimizedBlock  = block = m_OptimizedBlock;
            m_OptimizedBlockState = OptimizedBlockState.HasOptimizedBlock;
            return(true);
        }
Exemplo n.º 14
0
 public override void OnInspectorGUI()
 {
     if (this.IsMissingMonoBehaviourTarget() && this.MissingMonoBehaviourGUI())
     {
         return;
     }
     base.OnInspectorGUI();
     if (!(this.target is MonoBehaviour) || !AudioUtil.HaveAudioCallback(this.target as MonoBehaviour) || AudioUtil.GetCustomFilterChannelCount(this.target as MonoBehaviour) <= 0)
     {
         return;
     }
     if (this.m_AudioFilterGUI == null)
     {
         this.m_AudioFilterGUI = new AudioFilterGUI();
     }
     this.m_AudioFilterGUI.DrawAudioFilterGUI(this.target as MonoBehaviour);
 }