예제 #1
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        // Take out this if statement to set the value using setter when ever you change it in the inspector.
        // But then it gets called a couple of times when ever inspector updates
        // By having a button, you can control when the value goes through the setter and getter, your self.
        if (GUILayout.Button("Return Pool"))
        {
            if (target.GetType() == typeof(PoolMember))
            {
                PoolMember pm = (PoolMember)target;
                pm.ReturnPool();
                Debug.Log("Returned");
            }
        }
    }
예제 #2
0
    public void ReturnObject(GameObject ToReturn)
    {
        //if its in a pool return it to his pool
        PoolMember pm = ToReturn.GetComponent <PoolMember>();

        if (pm != null)
        {
            pm.ReturnPool();
            return;
        }

        //than its a NonPoolMember
        NonPoolMember npm = ToReturn.GetComponent <NonPoolMember>();

        if (npm != null)
        {
            //make it gone
            npm.Begone();
            return;
        }

        //else destroy him
        Destroy(ToReturn);
    }