コード例 #1
0
 /// <summary>
 /// Adds or remove items from the currentMineVisHelp list
 /// </summary>
 /// <param name="isToAdd">is is true we add otherwise remove</param>
 /// <param name="obj">the new obj</param>
 public void AddVisHelpList(bool isToAdd, TerrainRamdonSpawner obj)
 {
     if (isToAdd)
     {
         //print(obj.name + " added to selection");
         currentMineVisHelp.Add(SelectionGO.CreateSelection(Root.selectMine1, obj.transform.position, obj.IndexAllVertex,
                                                            obj.name + " Selection", container: transform));
     }
     else if (!isToAdd && currentMineVisHelp.Count > 0)
     {
         for (int i = 0; i < currentMineVisHelp.Count; i++)
         {
             if (currentMineVisHelp[i].IndexAllVertex == obj.IndexAllVertex)
             {
                 //print(currentMineVisHelp[i].IndexAllVertex + " currentMineVisHelp[i].IndexAllVertex");
                 //print(obj.IndexAllVertex + " obj.IndexAllVertex");
                 currentMineVisHelp[i].Destroy();
                 currentMineVisHelp.RemoveAt(i);
                 i--;
             }
         }
     }
     //updates the needed list on TerraSpawnController
     p.TerraSpawnController.UpdateLocalLists(obj);
 }
コード例 #2
0
    public int AllVertexIndex;//this is the correspondent allvertex index

    static public SelectionGO CreateSelection(string root, Vector3 origen, int indexAllVertex,
                                              string name = "", Transform container = null)
    {
        WAKEUP = true;
        SelectionGO obj = null;

        obj = (SelectionGO)Resources.Load(root, typeof(SelectionGO));
        obj = (SelectionGO)Instantiate(obj, origen, Quaternion.identity);
        if (name != "")
        {
            obj.name = name;
        }
        if (container != null)
        {
            obj.transform.SetParent(container);
        }
        obj.IndexAllVertex = indexAllVertex;
        return(obj);
    }