public static void SetParent(Component component, Transform parent, TransStayOption stayOption = TransStayOption.Non) { if (component == null) { return; } Transform trans = component.transform; switch (stayOption) { case TransStayOption.Local: trans.SetParent(parent, false); break; case TransStayOption.World: trans.SetParent(parent); break; default: trans.SetParent(parent, false); trans.localPosition = Vector3.zero; trans.localRotation = Quaternion.identity; trans.localScale = Vector3.one; break; } }
public static void SetParent(GameObject go, Transform parent, TransStayOption stayOption = TransStayOption.Non) { if (go == null) { return; } SetParent(go.transform, parent, stayOption); }
public static T Instantiate <T> (string path, Transform parent = null, TransStayOption stayOption = TransStayOption.Non) where T : Component { if (string.IsNullOrEmpty(path)) { return(null); } GameObject prefab = ResourceManager.Load <GameObject> (path); return(Instantiate <T> (prefab, parent, stayOption)); }
public static T Instantiate <T> (GameObject prefab, Transform parent = null, TransStayOption stayOption = TransStayOption.Non) where T : Component { GameObject go = Instantiate(prefab, parent, stayOption); if (go == null) { return(null); } return(go.GetComponent <T> ()); }
public static Component InstantiateOrCreateInChildren(System.Type type, string path, Transform parent = null, TransStayOption stayOption = TransStayOption.Non, bool includeInactive = false) { GameObject prefab = ResourceManager.Load <GameObject> (path); return(InstantiateOrCreateInChildren(type, prefab, parent, stayOption, includeInactive)); }
public static Component InstantiateOrCreateInChildren(System.Type type, GameObject prefab, Transform parent = null, TransStayOption stayOption = TransStayOption.Non, bool includeInactive = false) { GameObject go = InstantiateOrCreate(prefab, parent, stayOption); return(GetOrAddComponentInChildren(type, go, includeInactive)); }
public static T InstantiateOrCreateInChildren <T> (string path, Transform parent = null, TransStayOption stayOption = TransStayOption.Non, bool includeInactive = false) where T : Component { GameObject prefab = ResourceManager.Load <GameObject> (path); return(InstantiateOrCreateInChildren <T> (prefab, parent, stayOption, includeInactive)); }
public static T InstantiateOrCreateInChildren <T> (GameObject prefab, Transform parent = null, TransStayOption stayOption = TransStayOption.Non, bool includeInactive = false) where T : Component { GameObject go = InstantiateOrCreate(prefab, parent, stayOption); return(GetOrAddComponentInChildren <T> (go, includeInactive)); }
public static Component InstantiateOrCreate(System.Type type, string path, Transform parent = null, TransStayOption stayOption = TransStayOption.Non) { GameObject prefab = ResourceManager.Load <GameObject> (path); return(InstantiateOrCreate(type, prefab, parent, stayOption)); }
public static Component InstantiateOrCreate(System.Type type, GameObject prefab, Transform parent = null, TransStayOption stayOption = TransStayOption.Non) { GameObject go = InstantiateOrCreate(prefab, parent, stayOption); return(GetOrAddComponent(type, go)); }
public static T InstantiateOrCreate <T> (GameObject prefab, Transform parent = null, TransStayOption stayOption = TransStayOption.Non) where T : Component { GameObject go = InstantiateOrCreate(prefab, parent, stayOption); return(GetOrAddComponent <T> (go)); }
public static GameObject InstantiateOrCreate(string path, Transform parent = null, TransStayOption stayOption = TransStayOption.Non) { GameObject prefab = ResourceManager.Load <GameObject> (path); return(InstantiateOrCreate(prefab, parent, stayOption)); }
public static GameObject InstantiateOrCreate(GameObject prefab, Transform parent = null, TransStayOption stayOption = TransStayOption.Non) { GameObject go = prefab != null?Object.Instantiate(prefab) : new GameObject(); SetParent(go, parent, stayOption); return(go); }
public static GameObject Instantiate(GameObject prefab, Transform parent = null, TransStayOption stayOption = TransStayOption.Non) { if (prefab == null) { return(null); } GameObject go = Object.Instantiate(prefab); SetParent(go, parent, stayOption); return(go); }