/// <summary> /// Instantiate Object /// </summary> /// <param name="original"></param> /// <returns></returns> public static GameObject Instantiate(GameObject original) { GameObject clone = GameObject.Instantiate(original); #if UNITY_EDITOR LuaHelper.RefreshShader(clone as GameObject); #endif return(clone); }
/// <summary> /// /// </summary> /// <param name="original"></param> /// <param name="parent"></param> /// <returns></returns> public static GameObject InstantiateGlobal(GameObject original, GameObject parent = null) { var tranformTa = original.transform; var pos = tranformTa.position; Quaternion rota = tranformTa.rotation; Vector3 scale = tranformTa.localScale; GameObject clone = (GameObject)GameObject.Instantiate(original); #if UNITY_EDITOR if (clone is GameObject) { LuaHelper.RefreshShader(clone as GameObject); } #endif var transform = clone.transform; if (parent != null) { clone.transform.SetParent(parent.transform); } transform.position = pos; transform.localScale = scale; transform.rotation = rota; return(clone); }