vexe / VFW

MIT License
492 stars 67 forks source link

Resolve Name Conflict #55

Closed james7132 closed 9 years ago

james7132 commented 9 years ago

The Instantiate Extension functions were conflicting with the actual static methods in the UnityEngine.Object class, making calling the functions impossible.

Since the objects were already loaded in memory by the time the functions are called. I renamed them to Copy instead (since that's basically what the functions are doing at this point).

vexe commented 9 years ago

Can you give an example of how would the conflict happen? If you're inside a MonoBehaviour method and do: Instantiate, it should resolve to the static one unless you said this.Instantiate.

james7132 commented 9 years ago
public static class Visuals
{
    public static void CreateEffect(ParticleSystem effectPrefab)
   {
        effectPrefab.Instantiate ();
   }
}

It is a nice shortcut when not working strictly in a MonoBehaviour or ScriptableObject context.

vexe commented 9 years ago

Well then, I'd use InstantiateNew (or NewInstance) instead of Copy, cause Copy implies that you have an source and you're copying to it from a destination.

james7132 commented 9 years ago

Would Clone be OK? or would that be confusing with ICloneable implementers?

If not, I'll just use NewInstance.

vexe commented 9 years ago

Clone could be used as an extension method to do a serialize/deserialize to an object (deep copy) and ICloneable like you said. Just use InstantiateNew or NewInstance. I'd use the former cause it's sort of obvious what it's doing: Instantiate as opposed to NewInstance which could imply it's doing something different, just my opinion. Both are fine.

james7132 commented 9 years ago

It should be to InstantiateNew now.