예제 #1
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);
        }
예제 #2
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);
             }
         }
     }
 }
예제 #3
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);
                }
            }
        }
예제 #6
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);
                }
            }
        }
예제 #7
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);
        }
        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);
        }