private GameObject Instantiate(string strPrefab, Vector3 pos, Quaternion rot) { if (!strPrefab.IsLower()) { Debug.LogWarning(string.Concat("Converting prefab name to lowercase: ", strPrefab)); strPrefab = strPrefab.ToLower(); } GameObject gameObject = this.FindPrefab(strPrefab); if (!gameObject) { Debug.LogError(string.Concat("Couldn't find prefab \"", strPrefab, "\"")); return(null); } GameObject gameObject1 = this.pool.Pop(StringPool.Get(strPrefab), pos, rot); if (gameObject1 != null) { gameObject1.transform.localScale = gameObject.transform.localScale; } else { gameObject1 = Instantiate.GameObject(gameObject, pos, rot); gameObject1.name = strPrefab; } if (!this.Clientside && this.Serverside && gameObject1.transform.parent == null) { SceneManager.MoveGameObjectToScene(gameObject1, Rust.Server.EntityScene); } return(gameObject1); }
public void Rebuild() { this.options = ( from x in (IEnumerable <PieMenu.MenuOption>) this.options orderby x.order select x).ToArray <PieMenu.MenuOption>(); while (this.optionsCanvas.transform.childCount > 0) { if (!UnityEngine.Application.isPlaying) { UnityEngine.Object.DestroyImmediate(this.optionsCanvas.transform.GetChild(0).gameObject); } else { GameManager.DestroyImmediate(this.optionsCanvas.transform.GetChild(0).gameObject, true); } } float length = this.radiusSize / (float)((int)this.options.Length); for (int i = 0; i < (int)this.options.Length; i++) { GameObject gameObject = Instantiate.GameObject(this.pieOptionPrefab, null); gameObject.transform.SetParent(this.optionsCanvas.transform, false); this.options[i].option = gameObject.GetComponent <PieOption>(); this.options[i].option.UpdateOption(this.startRadius + (float)i * length - length * 0.25f, length, this.sliceGaps, this.options[i].name, this.outerSize, this.innerSize, this.iconSize, this.options[i].sprite); } this.selectedOption = null; }
private GameObject Instantiate(string strPrefab, Vector3 pos, Quaternion rot) { if (!StringEx.IsLower(strPrefab)) { Debug.LogWarning((object)("Converting prefab name to lowercase: " + strPrefab)); strPrefab = strPrefab.ToLower(); } GameObject prefab = this.FindPrefab(strPrefab); if (!Object.op_Implicit((Object)prefab)) { Debug.LogError((object)("Couldn't find prefab \"" + strPrefab + "\"")); return((GameObject)null); } GameObject gameObject = this.pool.Pop(StringPool.Get(strPrefab), pos, rot); if (Object.op_Equality((Object)gameObject, (Object)null)) { gameObject = Instantiate.GameObject(prefab, pos, rot); ((Object)gameObject).set_name(strPrefab); } else { gameObject.get_transform().set_localScale(prefab.get_transform().get_localScale()); } if (!this.Clientside && this.Serverside && Object.op_Equality((Object)gameObject.get_transform().get_parent(), (Object)null)) { SceneManager.MoveGameObjectToScene(gameObject, Rust.Server.EntityScene); } return(gameObject); }
public static GameObject InstantiateChild(this GameObject go, GameObject prefab) { GameObject go1 = Instantiate.GameObject(prefab, (Transform)null); go1.get_transform().SetParent(go.get_transform(), false); go1.Identity(); return(go1); }
public static GameObject InstantiateChild(this GameObject go, GameObject prefab) { GameObject gameObject = Instantiate.GameObject(prefab, null); gameObject.transform.SetParent(go.transform, false); gameObject.Identity(); return(gameObject); }
private void Awake() { if (Object.op_Equality((Object)this.prefabSource, (Object)null) || Object.op_Inequality((Object)this.createdGameObject, (Object)null)) { return; } this.createdGameObject = Instantiate.GameObject(this.prefabSource, (Transform)null); ((Object)this.createdGameObject).set_name(((Object)this.prefabSource).get_name()); this.createdGameObject.get_transform().SetParent(((Component)this).get_transform(), false); this.createdGameObject.Identity(); }
private void Awake() { if (this.prefabSource == null) { return; } if (this.createdGameObject != null) { return; } this.createdGameObject = Instantiate.GameObject(this.prefabSource, null); this.createdGameObject.name = this.prefabSource.name; this.createdGameObject.transform.SetParent(base.transform, false); this.createdGameObject.Identity(); }
BaseCombatEntity SpawnAttacker(string prefab, Vector3 position) { GameObject gameObject = Instantiate.GameObject(GameManager.server.FindPrefab(prefab), position, new Quaternion()); gameObject.name = prefab; SceneManager.MoveGameObjectToScene(gameObject, Rust.Server.EntityScene); UnityEngine.Object.Destroy(gameObject.GetComponent <Spawnable>()); if (!gameObject.activeSelf) { gameObject.SetActive(true); } return(gameObject.GetComponent <BaseCombatEntity>()); }
public void Process(string name, GameObject go) { if (go.CompareTag("NoPreProcessing")) { return; } GameObject hierarchyGroup = this.GetHierarchyGroup(); GameObject gameObject = go; go = Instantiate.GameObject(gameObject, hierarchyGroup.transform); go.name = gameObject.name; if (this.NeedsProcessing(go)) { this.ProcessObject(name, go, true); } this.AddPrefab(name, go); }
public void Rebuild() { this.options = ((IEnumerable <PieMenu.MenuOption>) this.options).OrderBy <PieMenu.MenuOption, int>((Func <PieMenu.MenuOption, int>)(x => x.order)).ToArray <PieMenu.MenuOption>(); while (this.optionsCanvas.get_transform().get_childCount() > 0) { GameManager.DestroyImmediate(((Component)this.optionsCanvas.get_transform().GetChild(0)).get_gameObject(), true); } float sliceSize = this.radiusSize / (float)this.options.Length; for (int index = 0; index < this.options.Length; ++index) { GameObject gameObject = Instantiate.GameObject(this.pieOptionPrefab, (Transform)null); gameObject.get_transform().SetParent(this.optionsCanvas.get_transform(), false); this.options[index].option = (PieOption)gameObject.GetComponent <PieOption>(); this.options[index].option.UpdateOption((float)((double)this.startRadius + (double)index * (double)sliceSize - (double)sliceSize * 0.25), sliceSize, this.sliceGaps, this.options[index].name, this.outerSize, this.innerSize, this.iconSize, this.options[index].sprite); } this.selectedOption = (PieMenu.MenuOption)null; }
private BaseEntity InstantiateEntity(string type, Vector3 position) { var gameObject = Instantiate.GameObject(GameManager.server.FindPrefab(type), position, new Quaternion()); gameObject.name = type; SceneManager.MoveGameObjectToScene(gameObject, Rust.Server.EntityScene); UnityEngine.Object.Destroy(gameObject.GetComponent <Spawnable>()); if (!gameObject.activeSelf) { gameObject.SetActive(true); } BaseEntity component = gameObject.GetComponent <BaseEntity>(); return(component); }
public static T Instantiate <T>(this T component) where T : Component { return(Instantiate.GameObject(component.gameObject, null).GetComponent <T>()); }
public GameObject Instantiate(Transform parent = null) { return(Instantiate.GameObject(this.Get(), parent)); }
public static T Instantiate <T>(this T component) where T : Component { return(Instantiate.GameObject(((Component)(object)component).get_gameObject(), (Transform)null).GetComponent <T>()); }