private SoundSetting GetSettings <TEnum>(TEnum sound) where TEnum : struct, IComparable, IConvertible, IFormattable { var type = typeof(TEnum); var value = EnumInt32ToInt.Convert(sound); var key = new EnumComparerKey(type, value); if (SoundSettings.ContainsKey(key) == false) { SoundSettings[key] = SoundSetting.Default; } return(SoundSettings[key]); }
private SoundSetting GetResultingSetting(Type type, int value) { var key = new EnumComparerKey(type, value); var groupSetting = GroupSettings.ContainsKey(type) ? GroupSettings[type] : SoundSetting.Default; var soundSetting = SoundSettings.ContainsKey(key) ? SoundSettings[key] : SoundSetting.Default; var resultingSetting = new SoundSetting(); resultingSetting.Mute = GlobalSettings.Mute || groupSetting.Mute || soundSetting.Mute; resultingSetting.Pitch = GlobalSettings.Pitch * groupSetting.Pitch * soundSetting.Pitch; resultingSetting.Volume = GlobalSettings.Volume * groupSetting.Volume * soundSetting.Volume; return(resultingSetting); }
private void SetSettings <TEnum>(TEnum sound, SoundSetting setting) where TEnum : struct, IComparable, IConvertible, IFormattable { using (var list = GetPlayingAudioItemsCopy(sound)) { var type = typeof(TEnum); var value = EnumInt32ToInt.Convert(sound); var key = new EnumComparerKey(type, value); SoundSettings[key] = setting; foreach (var item in list) { ApplySetting(item); } } }
private UnityEngine.Object GetAsset(Type type, int value, string name) { var key = new EnumComparerKey(type, value); if (ResourceCache.ContainsKey(key) == false) { var path = GetPathFromNamespace(type, name); var asset = Resources.Load <UnityEngine.Object>(path); if (asset == null) { throw new UnityException("Can't load resource '" + path + "'"); } ResourceCache[key] = asset; } return(ResourceCache[key]); }
public void Release <TEnum>(TEnum resource) where TEnum : struct, IComparable, IConvertible, IFormattable { var type = typeof(TEnum); int value = EnumInt32ToInt.Convert(resource); var key = new EnumComparerKey(type, value); ResourceCache.Remove(key); for (int i = Pool.Count - 1; i >= 0; i--) { var item = Pool[i]; if (item.EnumType == type && item.EnumValue == value) { Pool.RemoveAt(i); break; } } }
//load form fbx public AnimationClip LoadAnimationClip <TEnum>(TEnum resource) where TEnum : struct, IComparable, IConvertible, IFormattable { var type = typeof(TEnum); int value = EnumInt32ToInt.Convert(resource); var name = resource.ToString(); var key = new EnumComparerKey(type, value); if (ResourceCache.ContainsKey(key) == false) { var path = GetPathFromNamespace(type, name); var asset = Resources.Load <GameObject>(path); if (asset == null) { throw new UnityException("Can't load resource '" + name + "'"); } ResourceCache[key] = asset.GetComponent <Animation>().clip; } return(ResourceCache[key] as AnimationClip); }