/// <summary>
    /// Currently creates and displays the prefab.
    /// If the manager has one create of the same type of IconLocObject
    /// If will reset that one
    ///
    /// Returns the newly set iconlocobject
    ///
    /// Duration of -1 means that the icon will last until its object is gone
    /// </summary>
    protected IconLocObject DrawIcon(float duration = -1)
    {
        FUI2dLocManager ILM = FUI2dLocManager.GetLM;

        if (ILM == null)
        {
            Debug.LogWarning("FUI2dLocManager has not been created yet");
            return(null);
        }
        else
        {
            // Debug.LogWarning("**** "+gameObject.name + " Going to spawn Icon");
            if (allowSpawn)
            {
                //cacheObject = null;
                cacheObject = ILM.CreateIcon(prefab, SpawnType, isTarget3D, this.gameObject, duration);
                if (cacheObject != null)
                {
                    isDrawn = true;
                    return(cacheObject);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
    }
 public void ReleaseIcon(IconLocObject obj)
 {
     // if using a prefab, destroy it
     if (obj.MyType == IconLocObjectTypes.PrefabIconLoc)
     {
         Destroy(obj.gameObject);
     }
     // other wise free up in the pool
     else
     {
         obj.Deactivate();
     }
 }
    public IconLocObject CreateIcon(IconLocObject prefab, IconLocObjectTypes type, bool target3D, GameObject target, float duration = -1)
    {
        //Debug.LogWarning("Entered FUI2dLoc Manager Create Icon");
        // We're fully init!  We can create icons objects
        if (isFullyInit)
        {
            //Debug.LogWarning("*****isFullyInit ****");
            IconLocObject newIconObject = null;

            // if we're not using a prefab, set it to the index of the type
            if (type != IconLocObjectTypes.PrefabIconLoc)
            {
                // a spawner is requesting to draw an object.  before we just create it, we
                // want to make sure we dont have one available
                // Which list are we looking at?
                bool reusedObject = false;
                switch (type)
                {
                case IconLocObjectTypes.CannonIconLoc: {
                    //Debug.LogWarning("Checking Cannons List");
                    foreach (IconLocObject tempRef in poolIconLocCannons)
                    {
                        if (!tempRef.IsActive)
                        {
                            newIconObject = tempRef;
                            reusedObject  = true;
                            break;
                        }
                    }
                    break;
                }

                case IconLocObjectTypes.EnemyIconLoc: {
                    //Debug.LogWarning("Checking EnemyIcon List");
                    foreach (IconLocObject tempRef in poolIconLocAlerts)
                    {
                        if (!tempRef.IsActive)
                        {
                            newIconObject = tempRef;
                            reusedObject  = true;
                            break;
                        }
                    }
                    break;
                }

                case IconLocObjectTypes.PowerUpIconLoc: {
                    foreach (IconLocObject tempRef in poolIconLocPowerUps)
                    {
                        if (!tempRef.IsActive)
                        {
                            newIconObject = tempRef;
                            reusedObject  = true;
                            break;
                        }
                    }
                    break;
                }

                case IconLocObjectTypes.PhaseNotifIconLoc: {
                    foreach (IconLocObject tempRef in poolIconLocPhaseNotif)
                    {
                        if (!tempRef.IsActive)
                        {
                            newIconObject = tempRef;
                            reusedObject  = true;
                            break;
                        }
                    }
                    break;
                }

                case IconLocObjectTypes.CommandCenterLoc: {
                    foreach (IconLocObject tempRef in poolIconLocCC)
                    {
                        if (!tempRef.IsActive)
                        {
                            newIconObject = tempRef;
                            reusedObject  = true;
                            break;
                        }
                    }
                    break;
                }
                }


                // we couldn't reuse one, so we create another
                if (!reusedObject)
                {
                    newIconObject = NGUITools.AddChild(_myPanel.gameObject, ListOfPrefabs[(int)type].gameObject).GetComponent <IconLocObject>();
                    // TODO: Testing just destroyed, weird bug going on...
                    switch (type)
                    {
                    case IconLocObjectTypes.CannonIconLoc: {
                        poolIconLocCannons.Add(newIconObject);
                        break;
                    }

                    case IconLocObjectTypes.EnemyIconLoc: {
                        poolIconLocAlerts.Add(newIconObject);
                        break;
                    }

                    case IconLocObjectTypes.PowerUpIconLoc: {
                        poolIconLocPowerUps.Add(newIconObject);
                        break;
                    }

                    case IconLocObjectTypes.PhaseNotifIconLoc: {
                        poolIconLocPhaseNotif.Add(newIconObject);
                        break;
                    }

                    case IconLocObjectTypes.CommandCenterLoc: {
                        poolIconLocCC.Add(newIconObject);
                        break;
                    }
                    }
                }
            }
            else
            {
                // we want to use a prefab, but make sure we do have a prefab.
                // if we dont, then use the prefab set to the prefab index, first in the list, and is a backup default
                if (prefab != null)
                {
                    // who ever asked to draw the icon did not give a prefab
                    // use default
                    newIconObject = NGUITools.AddChild(_myPanel.gameObject, prefab.gameObject).GetComponent <IconLocObject>();
                }
                else
                {
                    //newIconObject = NGUITools.AddChild(_myPanel.gameObject, DefaultIconLocPrefab.gameObject).GetComponent<IconLocObject>();
                    newIconObject = NGUITools.AddChild(_myPanel.gameObject, ListOfPrefabs[(int)IconLocObjectTypes.PrefabIconLoc].gameObject).GetComponent <IconLocObject>();
                }
            }



            // currently only called the base init, we want to call the derived init
            newIconObject.Init(this, type, target, target3D, duration);

            // ****** Return the new Icon Object ******* //
            return(newIconObject);
        }
        else
        {
            return(null);
        }
    }
 void OnDisable()
 {
     cacheObject = null;
 }