Exemple #1
0
        public void AddExposedParameter(AudioParameterPath path)
        {
            if (!ContainsExposedParameter(path.parameter))
            {
                List <ExposedAudioParameter> parameters = new List <ExposedAudioParameter>(exposedParameters);
                ExposedAudioParameter        newParam   = new ExposedAudioParameter();
                newParam.name = FindUniqueParameterName("MyExposedParam", exposedParameters);
                newParam.guid = path.parameter;
                parameters.Add(newParam);

                // We sort the exposed params by path
                parameters.Sort(SortFuncForExposedParameters);

                exposedParameters = parameters.ToArray();
                OnChangedExposedParameter();

                //Cache the path!
                exposedParamCache[path.parameter] = path;

                AudioMixerUtility.RepaintAudioMixerAndInspectors();
            }
            else
            {
                Debug.LogError("Cannot expose the same parameter more than once!");
            }
        }
 public static bool Slider(GUIContent label, ref float value, float displayScale, float displayExponent, string unit, float leftValue, float rightValue, AudioMixerController controller, AudioParameterPath path, params GUILayoutOption[] options)
 {
     EditorGUI.BeginChangeCheck();
     float fieldWidth = EditorGUIUtility.fieldWidth;
     string kFloatFieldFormatString = EditorGUI.kFloatFieldFormatString;
     bool flag = controller.ContainsExposedParameter(path.parameter);
     EditorGUIUtility.fieldWidth = 70f;
     EditorGUI.kFloatFieldFormatString = "F2";
     EditorGUI.s_UnitString = unit;
     GUIContent content = label;
     if (flag)
     {
         content = GUIContent.Temp(label.text + " ➔", label.tooltip);
     }
     float num2 = value * displayScale;
     num2 = EditorGUILayout.PowerSlider(content, num2, leftValue * displayScale, rightValue * displayScale, displayExponent, options);
     EditorGUI.s_UnitString = null;
     EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString;
     EditorGUIUtility.fieldWidth = fieldWidth;
     if ((Event.current.type == EventType.ContextClick) && GUILayoutUtility.topLevel.GetLast().Contains(Event.current.mousePosition))
     {
         ParameterTransitionType type;
         Event.current.Use();
         GenericMenu menu = new GenericMenu();
         if (!flag)
         {
             if (<>f__mg$cache0 == null)
             {
		public static bool Slider(GUIContent label, ref float value, float displayScale, float displayExponent, string unit, float leftValue, float rightValue, AudioMixerController controller, AudioParameterPath path, params GUILayoutOption[] options)
		{
			EditorGUI.BeginChangeCheck();
			float fieldWidth = EditorGUIUtility.fieldWidth;
			string kFloatFieldFormatString = EditorGUI.kFloatFieldFormatString;
			bool flag = controller.ContainsExposedParameter(path.parameter);
			EditorGUIUtility.fieldWidth = 70f;
			EditorGUI.kFloatFieldFormatString = "F2";
			EditorGUI.s_UnitString = unit;
			GUIContent label2 = label;
			if (flag)
			{
				label2 = GUIContent.Temp(label.text + " ➔", label.tooltip);
			}
			float num = value * displayScale;
			num = EditorGUILayout.PowerSlider(label2, num, leftValue * displayScale, rightValue * displayScale, displayExponent, options);
			EditorGUI.s_UnitString = null;
			EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString;
			EditorGUIUtility.fieldWidth = fieldWidth;
			if (Event.current.type == EventType.ContextClick && GUILayoutUtility.topLevel.GetLast().Contains(Event.current.mousePosition))
			{
				Event.current.Use();
				GenericMenu genericMenu = new GenericMenu();
				if (!flag)
				{
					genericMenu.AddItem(new GUIContent("Expose '" + path.ResolveStringPath(false) + "' to script"), false, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ExposePopupCallback), new AudioMixerEffectGUI.ExposedParamContext(controller, path));
				}
				else
				{
					genericMenu.AddItem(new GUIContent("Unexpose"), false, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.UnexposePopupCallback), new AudioMixerEffectGUI.ExposedParamContext(controller, path));
				}
				ParameterTransitionType parameterTransitionType;
				bool transitionTypeOverride = controller.TargetSnapshot.GetTransitionTypeOverride(path.parameter, out parameterTransitionType);
				genericMenu.AddSeparator(string.Empty);
				genericMenu.AddItem(new GUIContent("Linear Snapshot Transition"), parameterTransitionType == ParameterTransitionType.Lerp, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Lerp));
				genericMenu.AddItem(new GUIContent("Smoothstep Snapshot Transition"), parameterTransitionType == ParameterTransitionType.Smoothstep, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Smoothstep));
				genericMenu.AddItem(new GUIContent("Squared Snapshot Transition"), parameterTransitionType == ParameterTransitionType.Squared, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Squared));
				genericMenu.AddItem(new GUIContent("SquareRoot Snapshot Transition"), parameterTransitionType == ParameterTransitionType.SquareRoot, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.SquareRoot));
				genericMenu.AddItem(new GUIContent("BrickwallStart Snapshot Transition"), parameterTransitionType == ParameterTransitionType.BrickwallStart, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.BrickwallStart));
				genericMenu.AddItem(new GUIContent("BrickwallEnd Snapshot Transition"), parameterTransitionType == ParameterTransitionType.BrickwallEnd, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.BrickwallEnd));
				genericMenu.AddSeparator(string.Empty);
				genericMenu.ShowAsContext();
			}
			if (EditorGUI.EndChangeCheck())
			{
				value = num / displayScale;
				return true;
			}
			return false;
		}
        public string ResolveExposedParameterPath(GUID parameter, bool getOnlyBasePath)
        {
            //consult the cache of parameters first.
            if (exposedParamCache.ContainsKey(parameter))
            {
                AudioParameterPath path = exposedParamCache[parameter];

                return(path.ResolveStringPath(getOnlyBasePath));
            }

            //Search through the whole mixer!
            List <AudioMixerGroupController> groups = GetAllAudioGroupsSlow();

            foreach (AudioMixerGroupController group in groups)
            {
                if (group.GetGUIDForVolume() == parameter ||
                    group.GetGUIDForPitch() == parameter ||
                    group.GetGUIDForSend() == parameter)
                {
                    AudioGroupParameterPath newPath = new AudioGroupParameterPath(group, parameter);
                    exposedParamCache[parameter] = newPath;
                    return(newPath.ResolveStringPath(getOnlyBasePath));
                }
                else
                {
                    for (int i = 0; i < group.effects.Length; i++)
                    {
                        AudioMixerEffectController effect    = group.effects[i];
                        MixerParameterDefinition[] paramDefs = MixerEffectDefinitions.GetEffectParameters(effect.effectName);

                        for (int j = 0; j < paramDefs.Length; j++)
                        {
                            GUID guid = effect.GetGUIDForParameter(paramDefs[j].name);
                            if (guid == parameter)
                            {
                                AudioEffectParameterPath newPath = new AudioEffectParameterPath(group, effect, parameter);
                                exposedParamCache[parameter] = newPath;
                                return(newPath.ResolveStringPath(getOnlyBasePath));
                            }
                        }
                    }
                }
            }
            return("Error finding Parameter path");
        }
Exemple #5
0
        public void AddExposedParameter(AudioParameterPath path)
        {
            if (path == null)
            {
                Debug.LogError("Trying to expose null parameter.");
                return;
            }

            if (path.parameter == default)
            {
                Debug.LogError("Trying to expose parameter with default GUID.");
                return;
            }

            if (ContainsExposedParameter(path.parameter))
            {
                Debug.LogError("Cannot expose the same parameter more than once.");
                return;
            }

            var parameters = new List <ExposedAudioParameter>(exposedParameters);
            var newParam   = new ExposedAudioParameter();

            newParam.name = FindUniqueParameterName("MyExposedParam", exposedParameters);
            newParam.guid = path.parameter;
            parameters.Add(newParam);

            // We sort the exposed params by path
            parameters.Sort(SortFuncForExposedParameters);

            exposedParameters = parameters.ToArray();
            OnChangedExposedParameter();

            //Cache the path!
            exposedParamCache[path.parameter] = path;

            AudioMixerUtility.RepaintAudioMixerAndInspectors();
        }
			public ExposedParamContext(AudioMixerController controller, AudioParameterPath path)
			{
				this.controller = controller;
				this.path = path;
			}
 public void AddExposedParameter(AudioParameterPath path)
 {
   if (!this.ContainsExposedParameter(path.parameter))
   {
     List<ExposedAudioParameter> exposedAudioParameterList = new List<ExposedAudioParameter>((IEnumerable<ExposedAudioParameter>) this.exposedParameters);
     exposedAudioParameterList.Add(new ExposedAudioParameter()
     {
       name = this.FindUniqueParameterName("MyExposedParam", this.exposedParameters),
       guid = path.parameter
     });
     exposedAudioParameterList.Sort(new Comparison<ExposedAudioParameter>(this.SortFuncForExposedParameters));
     this.exposedParameters = exposedAudioParameterList.ToArray();
     this.OnChangedExposedParameter();
     this.exposedParamCache[path.parameter] = path;
     AudioMixerUtility.RepaintAudioMixerAndInspectors();
   }
   else
     Debug.LogError((object) "Cannot expose the same parameter more than once!");
 }