/// <summary>
 /// This removes a data group to this VisManager.
 /// </summary>
 /// <param name="dataGroup">
 /// This is the data group to remove.
 /// </param>
 public void RemoveDataGroup(VisDataGroup dataGroup)
 {
     //Make sure the data group is not null, and it is already in this VisManager.
     if (dataGroup != null && m_oDataGroups.Contains(dataGroup))
     {
         //remove the data group
         m_oDataGroups.Remove(dataGroup);
     }
 }
    /// <summary>
    /// This function is called by the base editor to display normal custom inspector gui.
    /// </summary>
    protected override void CustomInspectorGUI()
    {
        base.CustomInspectorGUI();

        VisDataGroup dataGroup = target as VisDataGroup;

        if (dataGroup == null)
        {
            return;
        }

        dataGroup.dataGroupName            = EditorGUILayout.TextField("  Data Group Name", dataGroup.dataGroupName);
        dataGroup.numberSubDataGroups      = Math.Abs(EditorGUILayout.IntField("  Sub Group Count", dataGroup.numberSubDataGroups));
        dataGroup.frequencyRangeStartIndex = EditorGUILayout.IntSlider("  Frequency Range Start Index", dataGroup.frequencyRangeStartIndex, 0, dataGroup.frequencyRangeEndIndex - 1);
        dataGroup.frequencyRangeEndIndex   = EditorGUILayout.IntSlider("  Frequency Range End Index", dataGroup.frequencyRangeEndIndex, dataGroup.frequencyRangeStartIndex + 1, (dataGroup.Manager != null ? (int)dataGroup.Manager.windowSize : 4096) - 1);
        dataGroup.boost      = Mathf.Abs(EditorGUILayout.FloatField("  Boost", dataGroup.boost));
        dataGroup.cutoff     = Mathf.Abs(EditorGUILayout.FloatField("  Cutoff", dataGroup.cutoff));
        dataGroup.debugColor = EditorGUILayout.ColorField("  Debug Color", dataGroup.debugColor);
    }
    /// <summary>
    /// This is the function that is called by the base editor in order to display the custom inspector gui for required target objects.
    /// </summary>
    /// <returns>Whether or not the custom inspector gui found valid targets.</returns>
    protected override bool TargetInspectorGUI()
    {
        bool result = DisplayIVisManagerTargetGUI(target as IVisManagerTarget);

        VisDataGroup dataGroup = target as VisDataGroup;

        if (dataGroup != null &&
            !dataGroup.ValidateManager(false))
        {
            GUIStyle style = new GUIStyle(EditorStyles.boldLabel);
            style.normal.textColor = Color.white;
            style.wordWrap         = true;
            style.alignment        = TextAnchor.MiddleCenter;

            Color oldColor = GUI.color;
            GUI.color = new Color(1.0f, 0.0f, 0.0f);
            GUILayout.Label("To prevent issues, please make sure this Data Group is attached to the same Game Object as it's Manager.", style);
            GUI.color = oldColor;
        }

        return(result);
    }
Ejemplo n.º 4
0
	/// <summary>
	/// This removes a data group to this VisManager. 
	/// </summary>
	/// <param name="dataGroup">
	/// This is the data group to remove.
	/// </param>
	public void RemoveDataGroup(VisDataGroup dataGroup)
	{
		//Make sure the data group is not null, and it is already in this VisManager.
		if (dataGroup != null && m_oDataGroups.Contains(dataGroup))
		{
			//remove the data group
			m_oDataGroups.Remove(dataGroup);
		}
	}	
Ejemplo n.º 5
0
	/// <summary>
	/// This adds a data group to this VisManager. 
	/// </summary>
	/// <param name="dataGroup">
	/// This is the data group to add.
	/// </param>
    public void AddDataGroup(VisDataGroup dataGroup)
    {
		//Make sure the data group is not null, and it is not already in this VisManager.
        if (dataGroup != null && m_oDataGroups != null && m_oDataGroups.Contains(dataGroup) == false &&
            (dataGroup.Manager != this || GetDataGroupByName(dataGroup.dataGroupName) == null))
        {
            //make sure there is not a controller already in here with the game object name and controller name the same
            for (int i = 0; i < m_oDataGroups.Count; i++)
            {
                if (m_oDataGroups[i].name == dataGroup.name &&
                    m_oDataGroups[i].dataGroupName == dataGroup.dataGroupName)
                {
                    //this object may already be in there, ignore it!
                    return;
                }
            }

            //force unique name
            dataGroup.dataGroupName = EnsureUniqueDataGroupName(dataGroup.dataGroupName);

			//add the data group
            m_oDataGroups.Add(dataGroup);
            
            //check for data group overlap and warn
            for (int i = 0; i < m_oDataGroups.Count; i++)
            {
				//make sure the data group at this index is not the one we just added
                if (m_oDataGroups[i] != dataGroup &&
                    m_oDataGroups[i] != null)
                {
					//create var to store if there is an overlap
					bool overlapDetected = false;
					
					//check for an overlap with the of the start index of the just added data group.
                    if (dataGroup.frequencyRangeStartIndex >= m_oDataGroups[i].frequencyRangeStartIndex &&
                        dataGroup.frequencyRangeStartIndex <= m_oDataGroups[i].frequencyRangeEndIndex)
                    {
						overlapDetected = true;
                    }
					//check for an overlap with the of the end index of the just added data group.
                    else if (dataGroup.frequencyRangeEndIndex >= m_oDataGroups[i].frequencyRangeStartIndex &&
                             dataGroup.frequencyRangeEndIndex <= m_oDataGroups[i].frequencyRangeEndIndex)
                    {
						overlapDetected = true;
                    }					
					//check for an overlap with the of the start index of the indexed data group.
                    else if (m_oDataGroups[i].frequencyRangeStartIndex >= dataGroup.frequencyRangeStartIndex &&
                        	 m_oDataGroups[i].frequencyRangeStartIndex <= dataGroup.frequencyRangeEndIndex)
                    {
						overlapDetected = true; 
                    }
					//check for an overlap with the of the end index of the indexed data group.
                    else if (m_oDataGroups[i].frequencyRangeEndIndex >= dataGroup.frequencyRangeStartIndex &&
                             m_oDataGroups[i].frequencyRangeEndIndex <= dataGroup.frequencyRangeEndIndex)
                    {
						overlapDetected = true;
                    }
					
					//display warning
					if (overlapDetected)
					{						
                        Debug.LogWarning("Data Group \"" +
                                         dataGroup.dataGroupName +
                                         "\" has its frequency range overlapping with Data Group \"" +
                                         m_oDataGroups[i].dataGroupName +
                                         "\".  This is not recommended due to performance considerations.");
					}
                }
            }

        }
    }
    /// <summary>
    /// This adds a data group to this VisManager.
    /// </summary>
    /// <param name="dataGroup">
    /// This is the data group to add.
    /// </param>
    public void AddDataGroup(VisDataGroup dataGroup)
    {
        //Make sure the data group is not null, and it is not already in this VisManager.
        if (dataGroup != null && m_oDataGroups != null && m_oDataGroups.Contains(dataGroup) == false &&
            (dataGroup.Manager != this || GetDataGroupByName(dataGroup.dataGroupName) == null))
        {
            //make sure there is not a controller already in here with the game object name and controller name the same
            for (int i = 0; i < m_oDataGroups.Count; i++)
            {
                if (m_oDataGroups[i].name == dataGroup.name &&
                    m_oDataGroups[i].dataGroupName == dataGroup.dataGroupName)
                {
                    //this object may already be in there, ignore it!
                    return;
                }
            }

            //force unique name
            dataGroup.dataGroupName = EnsureUniqueDataGroupName(dataGroup.dataGroupName);

            //add the data group
            m_oDataGroups.Add(dataGroup);

            //check for data group overlap and warn
            for (int i = 0; i < m_oDataGroups.Count; i++)
            {
                //make sure the data group at this index is not the one we just added
                if (m_oDataGroups[i] != dataGroup &&
                    m_oDataGroups[i] != null)
                {
                    //create var to store if there is an overlap
                    bool overlapDetected = false;

                    //check for an overlap with the of the start index of the just added data group.
                    if (dataGroup.frequencyRangeStartIndex >= m_oDataGroups[i].frequencyRangeStartIndex &&
                        dataGroup.frequencyRangeStartIndex <= m_oDataGroups[i].frequencyRangeEndIndex)
                    {
                        overlapDetected = true;
                    }
                    //check for an overlap with the of the end index of the just added data group.
                    else if (dataGroup.frequencyRangeEndIndex >= m_oDataGroups[i].frequencyRangeStartIndex &&
                             dataGroup.frequencyRangeEndIndex <= m_oDataGroups[i].frequencyRangeEndIndex)
                    {
                        overlapDetected = true;
                    }
                    //check for an overlap with the of the start index of the indexed data group.
                    else if (m_oDataGroups[i].frequencyRangeStartIndex >= dataGroup.frequencyRangeStartIndex &&
                             m_oDataGroups[i].frequencyRangeStartIndex <= dataGroup.frequencyRangeEndIndex)
                    {
                        overlapDetected = true;
                    }
                    //check for an overlap with the of the end index of the indexed data group.
                    else if (m_oDataGroups[i].frequencyRangeEndIndex >= dataGroup.frequencyRangeStartIndex &&
                             m_oDataGroups[i].frequencyRangeEndIndex <= dataGroup.frequencyRangeEndIndex)
                    {
                        overlapDetected = true;
                    }

                    //display warning
                    if (overlapDetected)
                    {
                        Debug.LogWarning("Data Group \"" +
                                         dataGroup.dataGroupName +
                                         "\" has its frequency range overlapping with Data Group \"" +
                                         m_oDataGroups[i].dataGroupName +
                                         "\".  This is not recommended due to performance considerations.");
                    }
                }
            }
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// This displays the drop down for selecting a data group from the inspector.
    /// </summary>
    /// <param name="dataGroupTarget">The data group target to set the data group for.</param>
    /// <returns>Whether or not a data group is currently set.</returns>
    public bool DisplayIVisDataGroupTargetGUI(IVisDataGroupTarget dataGroupTarget)
    {
        EnsureAllDataGroupsRegistered();

        if (dataGroupTarget != null && dataGroupTarget is IVisManagerTarget)
        {
            //make sure and try to restore it first
            VisDataGroup.RestoreVisDataGroupTarget(dataGroupTarget);

            VisManager manager = (dataGroupTarget as IVisManagerTarget).Manager;
            if (manager != null)
            {
                ReadOnlyCollection <VisDataGroup> dataGroups = manager.DataGroups;
                if (dataGroups.Count > 0)
                {
                    //create list of vis data group names and a dictionary to map IDs, and sort it
                    List <string>            sortedNames    = new List <string>(dataGroups.Count);
                    Dictionary <string, int> nameToIndexMap = new Dictionary <string, int>(dataGroups.Count);
                    for (int i = 0; i < dataGroups.Count; i++)
                    {
                        sortedNames.Add((dataGroups[i] as VisDataGroup).dataGroupName);
                        nameToIndexMap.Add((dataGroups[i] as VisDataGroup).dataGroupName, i);
                    }
                    sortedNames.Sort();

                    //create array of names and set current index
                    int      currentIndex   = 0;
                    string[] displayedNames = new string[dataGroups.Count + 1];
                    displayedNames[0] = "None";
                    for (int i = 0; i < sortedNames.Count; i++)
                    {
                        displayedNames[i + 1] = sortedNames[i];
                        if (dataGroupTarget.DataGroup == dataGroups[nameToIndexMap[sortedNames[i]]])
                        {
                            currentIndex = i + 1;
                        }
                    }

                    //display popup
                    int newIndex = EditorGUILayout.Popup("   Data Group", currentIndex, displayedNames);

                    //set new vis data group if the index has changed
                    if (newIndex != currentIndex)
                    {
                        if (newIndex == 0)
                        {
                            dataGroupTarget.DataGroup = null;
                        }
                        else
                        {
                            string newName       = sortedNames[newIndex - 1];
                            int    remappedIndex = nameToIndexMap[newName];
                            dataGroupTarget.DataGroup = dataGroups[remappedIndex] as VisDataGroup;
                        }
                        EditorUtility.SetDirty(target);
                    }
                    return(dataGroupTarget.DataGroup != null);
                }
                else
                {
                    if (dataGroupTarget.LastDataGroupName != null && dataGroupTarget.LastDataGroupName.Length > 0)
                    {
                        EditorGUILayout.LabelField("   Data Group", dataGroupTarget.LastDataGroupName + " (not found, try selecting the Object with this Data Group)");
                    }
                    else
                    {
                        EditorGUILayout.LabelField("   Data Group", "NO DATA GROUPS FOUND!");
                    }
                    return(false);
                }
            }
        }
        return(false);
    }