Ejemplo n.º 1
0
    /// <summary>
    /// Adds an object to the selection, changes the shader and shows and hides the appropriate canvas
    /// </summary>
    /// <param name="go">The Gameobject which is added</param>
    protected void AddObjectToSecundarySelection(GameObject go, bool invokeSelectionChangeEvent = true)
    {
        if (secundarySelectedObjects.Contains(go))
        {
            return;
        }

        Selectable selectable = go.GetComponent <Selectable>();

        if (selectable == null)
        {
            throw new Exception("You tried to Add an GameObject which hans't a Selectable component on it: (Gameobject: " + go + ")");
        }
        selectable.SetShader(secundary: true);

        secundarySelectedObjects.Add(go);

        if (SecundarySelectionContainsListeners.ContainsKey(go))
        {
            foreach (var l in SecundarySelectionContainsListeners[go])
            {
                l.Invoke(go, secundarySelectedObjects.AsReadOnly());
            }
        }
        if (invokeSelectionChangeEvent && ChangeSecundarySelectionEvent != null)
        {
            ChangeSecundarySelectionEvent.Invoke(Array.AsReadOnly(new GameObject[] { go }), Array.AsReadOnly(new GameObject[] { }), SecundarySelectedObjects);
        }
    }
Ejemplo n.º 2
0
 public bool RemoveSecundarySelectionContainsListner(GameObject go, SelectionContains listener)
 {
     if (!SecundarySelectionContainsListeners.ContainsKey(go))
     {
         return(false);
     }
     return(SecundarySelectionContainsListeners[go].Remove(listener));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds a listner for an gameobject. If this gameobject is selected, the listner will be invoked
 /// </summary>
 /// <param name="go">the gameobject on which the listener should be registered</param>
 /// <param name="listener">the listener it self</param>
 /// <returns>the SelectionContains delgate which was given to this function</returns>
 public SelectionContains AddSecundarySelectionContainsListener(GameObject go, SelectionContains listener)
 {
     if (!SecundarySelectionContainsListeners.ContainsKey(go))
     {
         SecundarySelectionContainsListeners.Add(go, new List <SelectionContains>());
     }
     SecundarySelectionContainsListeners[go].Add(listener);
     return(listener);
 }