public void InitializeFromUpdatedEvent(FmodEvent src, FmodEvent oldEvent) { #if UNITY_EDITOR List <FmodEventParameter> newParams = new List <FmodEventParameter>(); List <FmodEventParameter> oldParams = oldEvent.getParameters(); EditorUtility.CopySerialized(src, this); hideFlags = HideFlags.HideInHierarchy; foreach (FmodEventParameter p in m_parameters) { FmodEventParameter newP = ScriptableObject.CreateInstance("FmodEventParameter") as FmodEventParameter; newP.Initialize(p, this); foreach (FmodEventParameter oldP in oldParams) { if (p.name == oldP.name) { newP.SetValue(oldP.getValue()); oldParams.Remove(oldP); break; } } newParams.Add(newP); } m_parameters = newParams; m_minRange = oldEvent.m_minRange; m_maxRange = oldEvent.m_maxRange; #endif }
public void SetSourceEvent(FmodEvent srcEvent) { if (m_source == srcEvent) { return; } CleanRuntimeEvent(); m_source = srcEvent; if (m_source != null) { UpdateRestorationData(); m_type = m_source.getSourceType(); setMaxRange(m_source.m_maxRange); setMinRange(m_source.m_minRange); if (m_parameters != null) { CleanAndRemoveParameters(); } else { m_parameters = new List <FmodRuntimeEventParameter>(); } foreach (FmodEventParameter p in m_source.getParameters()) { FmodRuntimeEventParameter runtimeParam = gameObject.AddComponent <FmodRuntimeEventParameter>(); runtimeParam.Initialize(p); m_parameters.Add(runtimeParam); } } else { CleanAndRemoveParameters(); } }
public void UpdateExistingEvent(FmodEvent newEvent) { #if UNITY_EDITOR List <FmodRuntimeEventParameter> oldParams = getParameters(); List <FmodRuntimeEventParameter> toRemove = new List <FmodRuntimeEventParameter>(); //checking for existing params foreach (FmodRuntimeEventParameter oldParam in oldParams) { FmodEventParameter matchingParam = newEvent.getParameter(oldParam.getName()); if (matchingParam == null) { toRemove.Add(oldParam); } else { oldParam.UpdateExistingParam(matchingParam); } } //removing previously existing params that have been deleted foreach (FmodRuntimeEventParameter toDelete in toRemove) { m_parameters.Remove(toDelete); DestroyImmediate(toDelete, true); } PrefabType prefabType = PrefabUtility.GetPrefabType(gameObject); // checking for newly created params if (prefabType != PrefabType.PrefabInstance && prefabType != PrefabType.ModelPrefabInstance) { foreach (FmodEventParameter newParam in newEvent.getParameters()) { if (ParameterExists(newParam.getName()) == false) { FmodRuntimeEventParameter runtimeParam = gameObject.AddComponent <FmodRuntimeEventParameter>(); runtimeParam.Initialize(newParam); m_parameters.Add(runtimeParam); } } } m_source = newEvent; #endif }
public List <FmodRuntimeEventParameter> getParameters() { int nbParamsInRuntimeParams = 0; foreach (FmodRuntimeEventParameter p in m_parameters) { if (p != null) { nbParamsInRuntimeParams++; } } if ((m_parameters == null || nbParamsInRuntimeParams == 0) && m_source != null && m_source.getParameters().Count > 0) { SetSourceEvent(m_source); } return(m_parameters); }
public void UpdateExistingEvent(FmodEvent newEvent) { #if UNITY_EDITOR List<FmodRuntimeEventParameter> oldParams = getParameters(); List<FmodRuntimeEventParameter> toRemove = new List<FmodRuntimeEventParameter>(); //checking for existing params foreach (FmodRuntimeEventParameter oldParam in oldParams) { FmodEventParameter matchingParam = newEvent.getParameter(oldParam.getName()); if (matchingParam == null) { toRemove.Add(oldParam); } else { oldParam.UpdateExistingParam(matchingParam); } } //removing previously existing params that have been deleted foreach (FmodRuntimeEventParameter toDelete in toRemove) { m_parameters.Remove(toDelete); DestroyImmediate(toDelete, true); } PrefabType prefabType = PrefabUtility.GetPrefabType(gameObject); // checking for newly created params if (prefabType != PrefabType.PrefabInstance && prefabType != PrefabType.ModelPrefabInstance) { foreach (FmodEventParameter newParam in newEvent.getParameters()) { if (ParameterExists(newParam.getName()) == false) { FmodRuntimeEventParameter runtimeParam = gameObject.AddComponent<FmodRuntimeEventParameter>(); runtimeParam.Initialize(newParam); m_parameters.Add(runtimeParam); } } } m_source = newEvent; #endif }
public void SetSourceEvent(FmodEvent srcEvent) { if (m_source == srcEvent) { return ; } CleanRuntimeEvent(); m_source = srcEvent; if (m_source != null) { UpdateRestorationData(); m_type = m_source.getSourceType(); setMaxRange(m_source.m_maxRange); setMinRange(m_source.m_minRange); if (m_parameters != null) { CleanAndRemoveParameters(); } else { m_parameters = new List<FmodRuntimeEventParameter>(); } foreach (FmodEventParameter p in m_source.getParameters()) { FmodRuntimeEventParameter runtimeParam = gameObject.AddComponent<FmodRuntimeEventParameter>(); runtimeParam.Initialize(p); m_parameters.Add(runtimeParam); } } else { CleanAndRemoveParameters(); } }
public void InitializeFromUpdatedEvent(FmodEvent src, FmodEvent oldEvent) { #if UNITY_EDITOR List<FmodEventParameter> newParams = new List<FmodEventParameter>(); List<FmodEventParameter> oldParams = oldEvent.getParameters(); EditorUtility.CopySerialized(src, this); hideFlags = HideFlags.HideInHierarchy; foreach (FmodEventParameter p in m_parameters) { FmodEventParameter newP = ScriptableObject.CreateInstance("FmodEventParameter") as FmodEventParameter; newP.Initialize(p, this); foreach (FmodEventParameter oldP in oldParams) { if (p.name == oldP.name) { newP.SetValue(oldP.getValue()); oldParams.Remove(oldP); break; } } newParams.Add(newP); } m_parameters = newParams; m_minRange = oldEvent.m_minRange; m_maxRange = oldEvent.m_maxRange; #endif }
public List <FmodEventParameter> getParameters() { return(m_source.getParameters()); }