Ejemplo n.º 1
0
    public PoolUnit UnitDefiner(PoolUnit p)
    {
        SpriteRenderer mSpr = p.GetComponent <SpriteRenderer>();

        if (!spr)
        {
            spr = GetComponent <SpriteRenderer>();
        }
        spr.drawMode         = mSpr.drawMode;
        transform.localScale = p.transform.localScale;
        transform.rotation   = Quaternion.Euler(0, 0, 0);
        spr.sortingOrder     = mSpr.sortingOrder;

        if (!boxC)
        {
            boxC = GetComponent <BoxCollider2D>();
        }
        BoxCollider2D mBoxC = p.GetComponent <BoxCollider2D>();

        boxC.size   = mBoxC.size;
        boxC.offset = mBoxC.offset;
        spr.size    = mSpr.size;
        spr.sprite  = mSpr.sprite;
        spr.color   = mSpr.color;
        return(this);
    }
Ejemplo n.º 2
0
    private void DrawDataUnitContent(PoolUnit <object> unit)
    {
        EditorGUILayout.BeginHorizontal();
        {
            GUILayout.Label(new GUIContent(unit.Storage.GetType().Name), EditorStyles.textField);

            GUILayout.Label(new GUIContent(unit.CacheTag.ToString()), EditorStyles.toolbarPopup, GUILayout.Width(110));
        }
        EditorGUILayout.EndHorizontal();
    }
Ejemplo n.º 3
0
    private void DrawAssetUnitSlot(string key, PoolUnit <Object> unit)
    {
        EditorGUILayout.BeginVertical("box");
        {
            GUILayout.Label(new GUIContent(key));

            DrawAssetUnitContent(unit);
        }
        EditorGUILayout.EndVertical();
    }
Ejemplo n.º 4
0
    private void DrawDataUnitSlot(string index, PoolUnit <object> unit)
    {
        EditorGUILayout.BeginVertical("box");
        {
            GUILayout.Label(new GUIContent(index));

            DrawDataUnitContent(unit);

            if (GUILayout.Button("Preview", EditorStyles.miniButton))
            {
                previewHeader = index;
                SetPreviewData(unit.Storage);
            }
        }
        EditorGUILayout.EndVertical();
    }
Ejemplo n.º 5
0
    public GameObject GetObjectFromPool(string name, Vector3 position, Quaternion rotation)
    {
        if (!isPoolMade)
        {
            return(null);
        }

        GameObject spawnobj;

        if (!poolDictionary.ContainsKey(name))
        {
            //Debug.LogError ("this key " + name + "doesnt exisaefowuhawfouhafoiht" + isPoolMade);
            return(null);
        }
        Stack <GameObject> poolStackMeta;

        poolStackMeta = poolDictionary [name];

        if (poolStackMeta.Count == 0)
        {
            PoolUnit pu = GetSourcePoolObjectFromName(name);
            spawnobj      = Instantiate(pu.prefab);
            spawnobj.name = name;
            spawnobj.transform.SetParent(pu.parent, false);
        }
        else
        {
            spawnobj = poolStackMeta.Pop();
        }
        spawnobj.SetActive(true);
        spawnobj.transform.position = position;
        spawnobj.transform.rotation = rotation;


        return(spawnobj);
    }
Ejemplo n.º 6
0
 public static void TurnOff(PoolUnit s)
 {
     s.gameObject.SetActive(false);
 }
Ejemplo n.º 7
0
 // desde el principio de la cursada que te lo hago recordar :^)
 public static void TurnOn(PoolUnit s)
 {
     s.gameObject.SetActive(true);
 }
Ejemplo n.º 8
0
 public void ReturnGeneric(PoolUnit generic)
 {
     myGenericPool.ReturnObject(generic);
 }
Ejemplo n.º 9
0
 public GenericSpawner(Transform t, Pool <PoolUnit> pool, string path)
 {
     _myGeneric    = Resources.Load <PoolUnit>("Prefabs/" + path);
     _transform    = t;
     myGenericPool = pool;
 }