Пример #1
0
        private void Start()
        {
            _audioListener = (AudioListener)UnityEngine.Object.FindObjectOfType(typeof(AudioListener));
            VolumeMeter component = base.gameObject.GetComponent <VolumeMeter>();

            if (component != null)
            {
                component.CollectAudioComponents();
            }
        }
Пример #2
0
 private void DrawVolumeMeters(VolumeMeter volumeMeter, float length)
 {
     GUILayout.BeginVertical("box");
     GUILayout.BeginHorizontal();
     GUILayout.FlexibleSpace();
     GUILayout.Label("VolumeMeter");
     GUILayout.FlexibleSpace();
     GUILayout.EndHorizontal();
     DrawMeter("FL", volumeMeter.volumeMeterState.mPeaks.mChannels[0], length);
     DrawMeter("FR", volumeMeter.volumeMeterState.mPeaks.mChannels[1], length);
     DrawMeter("RMS", volumeMeter.volumeMeterState.mRMS, length);
     GUILayout.EndVertical();
 }
Пример #3
0
 public void LoadAsset(string prefabName, string destinationComponent)
 {
     if (_globalComponentTable.ContainsKey(destinationComponent))
     {
         Component          component = _globalComponentTable[destinationComponent];
         UnityEngine.Object @object   = Resources.Load(prefabName);
         if (@object != null)
         {
             GameObject gameObject = UnityEngine.Object.Instantiate(@object) as GameObject;
             gameObject.name = gameObject.name.Replace("(Clone)", "");
             string key = destinationComponent + "_" + gameObject.name;
             if (_globalComponentTable.ContainsKey(key))
             {
                 UnityEngine.Object.Destroy(gameObject);
                 return;
             }
             gameObject.transform.parent = component.transform;
             Component component2 = gameObject.GetComponent <Component>();
             if (component2 != null)
             {
                 component2.Initialise(component, isComponentInstance: false);
                 component.AddComponent(component2);
                 AddChildComponentsToGlobalTable(component2, destinationComponent);
             }
             VolumeMeter component3 = component.GetComponent <VolumeMeter>();
             if (component3 != null)
             {
                 component3.CollectAudioComponents();
             }
             DebugLog.Print("Asset [" + prefabName + "] loaded succesfuly");
         }
         else
         {
             DebugLog.Print("Asset [" + prefabName + "] name not found", DebugLevel.Error);
         }
     }
     else
     {
         DebugLog.Print("Target Component [" + destinationComponent + "] not found", DebugLevel.Error);
     }
 }
Пример #4
0
 private void DrawComponent(Component component, ref float x, float y)
 {
     if (component.ToString().Contains("GroupComponent"))
     {
         GroupComponent groupComponent = (GroupComponent)component;
         if (!_soloComponents.Contains(groupComponent))
         {
             _soloComponents.Add(groupComponent);
         }
         component.ToString().LastIndexOf(".");
         string text = component.name;
         int    num  = text.Length * 10;
         float  num2 = slotHeight;
         if (num < 120)
         {
             num = 120;
         }
         VolumeMeter component2 = groupComponent.GetComponent <VolumeMeter>();
         if ((bool)component2)
         {
             num2 += 120f;
         }
         SideChain component3 = groupComponent.GetComponent <SideChain>();
         if ((bool)component3)
         {
             num2 += 120f;
         }
         GUILayout.BeginArea(new Rect(x, y, num, GetActualSize(num2)), text, GUI.skin.window);
         MixerSlot(text, groupComponent);
         if ((bool)component2)
         {
             DrawVolumeMeters(component2, GetActualSize(num - 10));
         }
         if ((bool)component3)
         {
             DrawSideChain(component3, GetActualSize(num - 30));
         }
         GUILayout.EndArea();
         x += num + 20;
     }
 }
Пример #5
0
 public void LoadAsset(GameObject component, string destinationComponent)
 {
     if (_globalComponentTable.ContainsKey(destinationComponent))
     {
         Component component2 = _globalComponentTable[destinationComponent];
         if (component != null)
         {
             component.name = component.name.Replace("(Clone)", "");
             string key = destinationComponent + "_" + component.name;
             if (_globalComponentTable.ContainsKey(key))
             {
                 UnityEngine.Object.DestroyImmediate(component);
                 return;
             }
             component.transform.parent = component2.transform;
             Component component3 = component.GetComponent <Component>();
             if (component3 != null)
             {
                 component3.Initialise(component2, isComponentInstance: false);
                 component2.AddComponent(component3);
                 AddChildComponentsToGlobalTable(component3, destinationComponent);
                 VolumeMeter component4 = component2.GetComponent <VolumeMeter>();
                 if (component4 != null)
                 {
                     component4.CollectAudioComponents();
                 }
             }
             DebugLog.Print("Asset [" + component.name + "] loaded succesfuly");
         }
         else
         {
             DebugLog.Print("Asset [" + component.name + "] name not found", DebugLevel.Error);
         }
     }
     else
     {
         DebugLog.Print("Target Component [" + destinationComponent + "] not found", DebugLevel.Error);
     }
 }
Пример #6
0
        public bool RegisterGroupComponent(GroupComponent groupComponent, string targetGroupComponentPath, bool createProxy = true)
        {
            if (!_allowExternalGroupComponents)
            {
                DebugLog.Print("External GroupComponent registration is disabled");
                return(false);
            }
            bool      result          = false;
            Component componentByName = GetComponentByName(targetGroupComponentPath);

            if (groupComponent != null)
            {
                groupComponent.Initialise(componentByName, isComponentInstance: false);
                if (componentByName != null)
                {
                    componentByName.AddComponent(groupComponent);
                }
                else
                {
                    _components.Add(groupComponent);
                }
                if (createProxy)
                {
                    GameObject gameObject = new GameObject();
                    gameObject.hideFlags = HideFlags.DontSave;
                    GroupComponentProxy groupComponentProxy = gameObject.AddComponent <GroupComponentProxy>();
                    groupComponentProxy._groupComponent = groupComponent;
                    groupComponentProxy.name            = groupComponent.name + "_Proxy";
                    if (componentByName != null)
                    {
                        groupComponentProxy.transform.parent = componentByName.transform;
                    }
                    else
                    {
                        groupComponentProxy.transform.parent = base.gameObject.transform;
                    }
                    _groupComponentProxies.Add(groupComponentProxy);
                }
                else if (componentByName != null)
                {
                    groupComponent.transform.parent = componentByName.transform;
                }
                else
                {
                    groupComponent.transform.parent = base.gameObject.transform;
                }
                if (componentByName != null)
                {
                    VolumeMeter component = componentByName.GetComponent <VolumeMeter>();
                    if (component != null)
                    {
                        component.CollectAudioComponents();
                    }
                }
                DebugLog.Print("GroupComponent [" + groupComponent.name + "] registred succesfuly");
                result = true;
            }
            else
            {
                DebugLog.Print("GroupComponent [" + groupComponent.name + "] failed to register", DebugLevel.Error);
            }
            return(result);
        }
Пример #7
0
 public void Update(Component component)
 {
     if (_parameters == null)
     {
         return;
     }
     for (int i = 0; i < _cachedValues.Length; i++)
     {
         _cachedValues[i] = 1f;
     }
     for (int j = 0; j < _parameters.Length; j++)
     {
         RTPParameterToProperty rTPParameterToProperty = _parameters[j];
         rTPParameterToProperty._parameter.Update();
         float num = 1f;
         _ = rTPParameterToProperty._property._min;
         _ = rTPParameterToProperty._property._max;
         if (rTPParameterToProperty._type == RTPParameterType.Distance || rTPParameterToProperty._parameter.Name == "Distance")
         {
             _ = 1f / (rTPParameterToProperty._parameter._max - rTPParameterToProperty._parameter._min);
             if (component.ParentGameObject != null)
             {
                 if (FabricManager.Instance._audioListener != null)
                 {
                     num = Vector3.Distance(component.ParentGameObject.transform.position, FabricManager.Instance._audioListener.transform.position);
                 }
                 else if (Camera.main != null)
                 {
                     num = Vector3.Distance(component.ParentGameObject.transform.position, Camera.main.transform.position);
                 }
                 rTPParameterToProperty._parameter.SetValue(num);
                 num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Modulator)
         {
             RTPModulator rtpModulator = rTPParameterToProperty._rtpModulator;
             if (rtpModulator != null)
             {
                 num = rtpModulator.GetValue(Time.time);
                 rTPParameterToProperty._parameter.SetValue(num);
                 num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Listener_Angle)
         {
             if (component.ParentGameObject != null)
             {
                 Vector3 from = default(Vector3);
                 Vector3 to   = default(Vector3);
                 if (FabricManager.Instance._audioListener != null)
                 {
                     from = Vector3.forward;
                     to   = FabricManager.Instance._audioListener.transform.forward;
                 }
                 else if (Camera.main != null)
                 {
                     from = Vector3.forward;
                     to   = Camera.main.transform.forward;
                 }
                 num = Vector3.Angle(from, to);
                 rTPParameterToProperty._parameter.SetValue(num);
                 num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Component_Angle)
         {
             if (component.ParentGameObject != null)
             {
                 Vector3 from2 = default(Vector3);
                 Vector3 to2   = default(Vector3);
                 if (FabricManager.Instance._audioListener != null)
                 {
                     from2 = component.ParentGameObject.transform.position - FabricManager.Instance._audioListener.transform.position;
                     to2   = component.ParentGameObject.transform.forward;
                 }
                 else if (Camera.main != null)
                 {
                     from2 = component.ParentGameObject.transform.position - Camera.main.transform.position;
                     to2   = component.ParentGameObject.transform.forward;
                 }
                 num = Vector3.Angle(from2, to2);
                 rTPParameterToProperty._parameter.SetValue(num);
                 num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Component_Velocity)
         {
             if (component.ParentGameObject != null)
             {
                 num = (component.ParentGameObject.transform.position - rTPParameterToProperty._previousPosition).magnitude / FabricTimer.GetRealtimeDelta();
                 rTPParameterToProperty._parameter.SetValue(num);
                 num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
                 rTPParameterToProperty._previousPosition = component.ParentGameObject.transform.position;
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Listener_Velocity)
         {
             if (FabricManager.Instance._audioListener != null)
             {
                 num = (FabricManager.Instance._audioListener.transform.position - rTPParameterToProperty._previousPosition).magnitude / FabricTimer.GetRealtimeDelta();
                 rTPParameterToProperty._previousPosition = FabricManager.Instance._audioListener.transform.position;
             }
             else if (Camera.main != null)
             {
                 num = (Camera.main.transform.position - rTPParameterToProperty._previousPosition).magnitude / FabricTimer.GetRealtimeDelta();
                 rTPParameterToProperty._previousPosition = Camera.main.transform.position;
             }
             rTPParameterToProperty._parameter.SetValue(num);
             num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Volume_Meter)
         {
             VolumeMeter volumeMeter = rTPParameterToProperty._volumeMeter;
             if (volumeMeter != null)
             {
                 num = volumeMeter.volumeMeterState.mRMS;
                 rTPParameterToProperty._parameter.SetValue(num);
                 num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Global_Parameter)
         {
             GlobalParameter globalParameter = EventManager.Instance._globalParameterManager._globalRTParameters.FindItem(rTPParameterToProperty._globalParameterName);
             if (globalParameter != null)
             {
                 rTPParameterToProperty._parameter._max = globalParameter._max;
                 rTPParameterToProperty._parameter._min = globalParameter._min;
                 rTPParameterToProperty._parameter.SetValue(globalParameter.GetCurrentValue());
                 num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Custom_Parameter)
         {
             ICustomRTPParameter customRTPParameter = FabricManager.Instance._customRTPParameter;
             if (customRTPParameter != null)
             {
                 num = customRTPParameter.UpdateProperty(component, rTPParameterToProperty._property, rTPParameterToProperty._propertyType);
                 num = CalculateNewValue(rTPParameterToProperty, num);
                 rTPParameterToProperty._parameter.SetValue(num);
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Max_Instances)
         {
             num = ((!(component.ComponentHolder != null)) ? 0f : ((float)component.ComponentHolder.GetNumActiveComponentInstances() / (float)component.MaxInstances));
             num = CalculateNewValue(rTPParameterToProperty, num);
             rTPParameterToProperty._parameter.SetValue(num);
         }
         else
         {
             num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
         }
         rTPParameterToProperty._property._value = num;
         if ((object)component != null)
         {
             _ = rTPParameterToProperty._property._property;
             _cachedValues[rTPParameterToProperty._property._property] *= num;
             ((IRTPPropertyListener)component).UpdateProperty(rTPParameterToProperty._property, _cachedValues[rTPParameterToProperty._property._property], rTPParameterToProperty._propertyType);
         }
     }
 }