public static GameObject Instantiate(GameObject prefabGo, Transform parent = null, TransformUtil.StayOption stayOption = TransformUtil.StayOption.Local) { if (prefabGo == null) { return(null); } switch (stayOption) { case TransformUtil.StayOption.Local: return(Object.Instantiate(prefabGo, parent, false)); case TransformUtil.StayOption.World: return(Object.Instantiate(prefabGo, parent, true)); default: // Reset var go = Object.Instantiate(prefabGo, parent, false); TransformUtil.Reset(go.transform); return(go); } }
public static T Instantiate <T> (T prefabCom, Transform parent = null, TransformUtil.StayOption stayOption = TransformUtil.StayOption.Local) where T : Component { if (prefabCom == null) { return(null); } switch (stayOption) { case TransformUtil.StayOption.Local: return(Object.Instantiate(prefabCom, parent, false)); case TransformUtil.StayOption.World: return(Object.Instantiate(prefabCom, parent, true)); default: // Reset var com = Object.Instantiate(prefabCom, parent, false); TransformUtil.Reset(com.transform); return(com); } }