1. So I'm trying to do something to avoid repeating the same code and changing just the object, I tought i could do it like this:

    Code:
    object getObjectList<T>()
            {
                return UnityEngine.Object.FindObjectsOfType<T>();
            }
    But it doesn't work, i never worked with generics before so i need a little hand in here, is there any way i could do something like this?
    [DOUBLEPOST=1437517919][/DOUBLEPOST]Edit: I currently use it like this:
    Code:
    new HashSet<Barricade>(UnityEngine.Object.FindObjectsOfType<Barricade>())
    
    But i don't want to do it for barricades, buildingblocks, traps etc etc, i just want a generic method.
     
  2. Calytic

    Calytic Community Admin Community Mod

    Haven't tested it but maybe something like this..

    Code:
    HashSet<T> getObjectList<T>() where T : UnityEngine.Object
            {
                return new HashSet<T>(UnityEngine.Object.FindObjectsOfType<T>());
            }
    
     
  3. Code:
    new HashSet<T>(UnityEngine.Object.FindObjectsOfType<T>());
    
    I've tried that before, it wont allow me to use T in FindObjectsOfType, says i cant cast 'T' as 'UnityEngine.Object'.

    EDIT: It worked, thanks alot man :)
     
  4. Calytic

    Calytic Community Admin Community Mod

    Yea, sorry I edited my post 2 seconds after I posted it.

    You needed the..
    Code:
     where T : UnityEngine.Object
     
  5. Yeah, thats all i added and it worked. Will be testing in around 15 mins, this will make everything smaller and cleaner :p
    [DOUBLEPOST=1437523794][/DOUBLEPOST]It worked and has been added to my plugin update:

    http://oxidemod.org/plugins/object-remover.1213/