public PureDataMultipleItem GetPureDataRandomItem(PureDataContainer container, List <int> childrenIds, object source) { PureDataMultipleItem randomAudioItem = new PureDataMultipleItem(container.Name, pureData); List <PureDataSubContainer> childcontainers = new List <PureDataSubContainer>(); List <float> weights = new List <float>(); for (int i = 0; i < childrenIds.Count; i++) { PureDataSubContainer childContainer = container.GetSubContainerWithID(childrenIds[i]); if (childContainer != null) { childcontainers.Add(childContainer); weights.Add(childContainer.weight); } } PureDataSubContainer randomChildContainer = HelperFunctions.WeightedRandom(childcontainers, weights); if (randomAudioItem != null) { PureDataItem childAudioItem = GetSubContainerAudioItem(container, randomChildContainer, source); if (childAudioItem != null) { randomAudioItem.AddItem(childAudioItem); } } return(randomAudioItem); }
public void Remove(PureDataContainer container) { if (parentId == 0) { container.childrenIds.Remove(id); } else { PureDataSubContainer parent = container.GetSubContainerWithID(parentId); if (parent != null) { parent.childrenIds.Remove(id); } } if (container.subContainers.Contains(this)) { container.subContainers.Remove(this); } foreach (int childrenId in childrenIds.ToArray()) { container.GetSubContainerWithID(childrenId).Remove(container); } }
public PureDataMultipleItem GetPureDataSwitchItem(PureDataContainer container, List <int> childrenIds, object source) { PureDataMultipleItem switchAudioItem = new PureDataMultipleItem(container.Name, pureData); int stateIndex = int.MinValue; PureDataSubContainer[] childrenSubContainers = container.IdsToSubContainers(childrenIds); if (childrenSubContainers[0].parentId == 0) { stateIndex = container.switchSettings.GetCurrentStateIndex(); } else { PureDataSubContainer parentSubContainer = container.GetSubContainerWithID(childrenSubContainers[0].parentId); stateIndex = parentSubContainer.switchSettings.GetCurrentStateIndex(); } if (stateIndex != int.MinValue) { foreach (PureDataSubContainer childSubContainer in childrenSubContainers) { if (childSubContainer.switchSettings.stateIndex == stateIndex) { PureDataItem childAudioItem = GetSubContainerAudioItem(container, childSubContainer, source); if (childAudioItem != null) { switchAudioItem.AddItem(childAudioItem); } } } } return(switchAudioItem); }
void ShowContainers() { containersProperty = containerManagerSerialized.FindProperty("containers"); if (AddFoldOut(containersProperty, "Containers".ToGUIContent())) { containerManager.containers[containerManager.containers.Length - 1] = new PureDataContainer("", pureData); containerManager.containers[containerManager.containers.Length - 1].SetUniqueName("default", containerManager.containers); } if (containersProperty.isExpanded) { EditorGUI.indentLevel += 1; for (int i = 0; i < containerManager.containers.Length; i++) { currentContainer = containerManager.containers[i]; currentContainerProperty = containersProperty.GetArrayElementAtIndex(i); BeginBox(); if (DeleteFoldOut(containersProperty, i, currentContainer.Name.ToGUIContent(), GetContainerStyle(currentContainer.type.ConvertByName <PureDataSubContainer.Types>()))) { break; } ShowContainer(); EndBox(); } Separator(); EditorGUI.indentLevel -= 1; } }
public PureDataContainer GetContainer(string containerName) { PureDataContainer container = null; try { container = containerDict[containerName]; } catch { Logger.LogError(string.Format("Container named {0} was not found.", containerName)); } return(container); }
public PureDataItem GetSubContainerAudioItem(PureDataContainer container, PureDataSubContainer subContainer, object source) { PureDataItem item = null; if (subContainer.IsSource) { item = GetPureDataSourceItem(subContainer, source); } else { item = GetPureDataContainerItem(container, subContainer, source); } return(item); }
public PureDataContainerItemInternal GetMixItem(PureDataContainer container, List <int> childrenIds, object source) { PureDataContainerItemInternal mixAudioItem = new PureDataContainerItemInternal(container.Name, pureData); foreach (int childrenId in childrenIds) { PureDataSourceOrContainerItem childItem = GetSubContainerItem(container, container.GetSubContainerWithID(childrenId), source); if (childItem != null) { mixAudioItem.AddItem(childItem); } } return(mixAudioItem); }
public PureDataMultipleItem GetPureDataMixItem(PureDataContainer container, List <int> childrenIds, object source) { PureDataMultipleItem mixAudioItem = new PureDataMultipleItem(container.Name, pureData); foreach (int childrenId in childrenIds) { PureDataItem childItem = GetSubContainerAudioItem(container, container.GetSubContainerWithID(childrenId), source); if (childItem != null) { mixAudioItem.AddItem(childItem); } } return(mixAudioItem); }
public PureDataContainerItemInternal GetContainerItem(PureDataContainer container, PureDataSubContainer subContainer, object source) { PureDataContainerItemInternal multipleAudioItem = null; switch (subContainer.type) { case PureDataSubContainer.Types.RandomContainer: multipleAudioItem = GetRandomItem(container, subContainer.childrenIds, source); break; case PureDataSubContainer.Types.SwitchContainer: multipleAudioItem = GetSwitchItem(container, subContainer.childrenIds, source); break; default: multipleAudioItem = GetMixItem(container, subContainer.childrenIds, source); break; } return multipleAudioItem; }
public PureDataSubContainer(PureDataContainer container, int parentId, PureDataSubContainer subContainer, PureData pureData) { this.Copy(subContainer, "id", "parentId", "childrenIds"); this.name = container.Name; this.id = container.GetUniqueID(); this.parentId = parentId; this.pureData = pureData; switchSettings = new PureDataSwitchSettings(pureData); if (parentId == 0) { container.childrenIds.Add(id); } else { container.GetSubContainerWithID(parentId).childrenIds.Add(id); } }
public PureDataSubContainer(PureDataContainer container, int parentId, PureData pureData) { this.name = container.Name; this.id = container.GetUniqueID(); this.parentId = parentId; this.pureData = pureData; this.switchSettings = new PureDataSwitchSettings(pureData); if (parentId == 0) { container.childrenIds.Add(id); } else { container.GetSubContainerWithID(parentId).childrenIds.Add(id); } }
void AdjustName(string prefix, PureDataSubContainer subContainer, PureDataContainer container) { subContainer.Name = prefix; if (subContainer.IsContainer) { subContainer.Name += string.Format(" ({0})", subContainer.childrenIds.Count); } if (GetParentContainerType(subContainer, container) == PureDataSubContainer.Types.RandomContainer) { subContainer.Name += " | Weight: " + subContainer.weight; } else if (GetParentContainerType(subContainer, container) == PureDataSubContainer.Types.SwitchContainer) { subContainer.Name += " | State: " + subContainer.switchSettings.stateName; } }
public PureDataContainerItemInternal GetContainerItem(PureDataContainer container, object source) { PureDataContainerItemInternal multipleItem; switch (container.type) { case PureDataContainer.Types.RandomContainer: multipleItem = GetRandomItem(container, container.childrenIds, source); break; case PureDataContainer.Types.SwitchContainer: multipleItem = GetSwitchItem(container, container.childrenIds, source); break; default: multipleItem = GetMixItem(container, container.childrenIds, source); break; } return(multipleItem); }
public PureDataMultipleItem GetPureDataContainerItem(PureDataContainer container, PureDataSubContainer subContainer, object source) { PureDataMultipleItem multipleAudioItem = null; switch (subContainer.type) { case PureDataSubContainer.Types.RandomContainer: multipleAudioItem = GetPureDataRandomItem(container, subContainer.childrenIds, source); break; case PureDataSubContainer.Types.SwitchContainer: multipleAudioItem = GetPureDataSwitchItem(container, subContainer.childrenIds, source); break; default: multipleAudioItem = GetPureDataMixItem(container, subContainer.childrenIds, source); break; } return(multipleAudioItem); }
public PureDataContainerItemInternal GetRandomItem(PureDataContainer container, List<int> childrenIds, object source) { PureDataContainerItemInternal randomAudioItem = new PureDataContainerItemInternal(container.Name, pureData); List<PureDataSubContainer> childcontainers = new List<PureDataSubContainer>(); List<float> weights = new List<float>(); for (int i = 0; i < childrenIds.Count; i++) { PureDataSubContainer childContainer = container.GetSubContainerWithID(childrenIds[i]); if (childContainer != null) { childcontainers.Add(childContainer); weights.Add(childContainer.weight); } } PureDataSubContainer randomChildContainer = HelperFunctions.WeightedRandom(childcontainers, weights); if (randomAudioItem != null) { PureDataSourceOrContainerItem childAudioItem = GetSubContainerItem(container, randomChildContainer, source); if (childAudioItem != null) { randomAudioItem.AddItem(childAudioItem); } } return randomAudioItem; }
public PureDataContainerItemInternal GetSwitchItem(PureDataContainer container, List<int> childrenIds, object source) { PureDataContainerItemInternal switchAudioItem = new PureDataContainerItemInternal(container.Name, pureData); int stateIndex = int.MinValue; PureDataSubContainer[] childrenSubContainers = container.IdsToSubContainers(childrenIds); if (childrenSubContainers[0].parentId == 0) { stateIndex = container.switchSettings.GetCurrentStateIndex(); } else { PureDataSubContainer parentSubContainer = container.GetSubContainerWithID(childrenSubContainers[0].parentId); stateIndex = parentSubContainer.switchSettings.GetCurrentStateIndex(); } if (stateIndex != int.MinValue) { foreach (PureDataSubContainer childSubContainer in childrenSubContainers) { if (childSubContainer.switchSettings.stateIndex == stateIndex) { PureDataSourceOrContainerItem childAudioItem = GetSubContainerItem(container, childSubContainer, source); if (childAudioItem != null) { switchAudioItem.AddItem(childAudioItem); } } } } return switchAudioItem; }
public PureDataContainerItemInternal GetMixItem(PureDataContainer container, List<int> childrenIds, object source) { PureDataContainerItemInternal mixAudioItem = new PureDataContainerItemInternal(container.Name, pureData); foreach (int childrenId in childrenIds) { PureDataSourceOrContainerItem childItem = GetSubContainerItem(container, container.GetSubContainerWithID(childrenId), source); if (childItem != null) { mixAudioItem.AddItem(childItem); } } return mixAudioItem; }
PureDataSubContainer.Types GetParentContainerType(PureDataSubContainer subContainer, PureDataContainer container) { PureDataSubContainer.Types type = PureDataSubContainer.Types.AudioSource; if (subContainer.parentId != 0) { type = container.GetSubContainerWithID(subContainer.parentId).type; } else { type = container.type.ConvertByName <PureDataSubContainer.Types>(); } return(type); }
PureDataSubContainer.Types GetParentContainerType(PureDataSubContainer subContainer, PureDataContainer container) { PureDataSubContainer.Types type = PureDataSubContainer.Types.AudioSource; if (subContainer.parentId != 0) { type = container.GetSubContainerWithID(subContainer.parentId).type; } else { type = container.type.ConvertByName<PureDataSubContainer.Types>(); } return type; }
public PureDataSourceOrContainerItem GetSubContainerItem(PureDataContainer container, PureDataSubContainer subContainer, object source) { PureDataSourceOrContainerItem item = null; if (subContainer.IsSource) { item = GetSourceItem(subContainer, source); } else { item = GetContainerItem(container, subContainer, source); } return item; }
void ShowContainers() { containersProperty = containerManagerSerialized.FindProperty("containers"); if (AddFoldOut(containersProperty, "Containers".ToGUIContent())) { containerManager.containers[containerManager.containers.Length - 1] = new PureDataContainer("", pureData); containerManager.containers[containerManager.containers.Length - 1].SetUniqueName("default", containerManager.containers); } if (containersProperty.isExpanded) { EditorGUI.indentLevel += 1; for (int i = 0; i < containerManager.containers.Length; i++) { currentContainer = containerManager.containers[i]; currentContainerProperty = containersProperty.GetArrayElementAtIndex(i); BeginBox(); if (DeleteFoldOut(containersProperty, i, currentContainer.Name.ToGUIContent(), GetContainerStyle(currentContainer.type.ConvertByName<PureDataSubContainer.Types>()))) { break; } ShowContainer(); EndBox(); } Separator(); EditorGUI.indentLevel -= 1; } }