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 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 }