public void PlaceObject() { if (gameObject == null) { UnityEngine.Object objPrefab = Resources.Load(prefab); if (objPrefab == null) { objPrefab = Resources.Load("Prefabs/Scenery/MissingModel"); } gameObject = (GameObject)Object.Instantiate(objPrefab, Vector3.zero, Quaternion.identity); //name = prefab; gameObject.name = name; foreach (ClickableObject CO in gameObject.transform.GetComponentsInChildren <ClickableObject>()) { CO.PlaceableObject = this; //This gets removed OnDestroy } } gameObject.transform.position = Pos; gameObject.transform.localScale = Scale; gameObject.transform.rotation = Rot; if (PlayerManager.Type != "BuilderPlayer") { DisableClickColliders(); } aSceneryComponent sc = gameObject.GetComponentInChildren <aSceneryComponent>(); if (sc != null) { sc.Init(this); } }
public void PlaceObject(Vector3 Pos, Vector3 LookAt, Vector3 scale) { this.Pos = Pos; if (gameObject == null) { UnityEngine.Object objPrefab = Resources.Load(prefab); if (objPrefab == null) { objPrefab = Resources.Load("Prefabs/Scenery/MissingModel"); } gameObject = (GameObject)Object.Instantiate(objPrefab, Vector3.zero, Quaternion.identity); gameObject.name = name; foreach (ClickableObject CO in gameObject.transform.GetComponentsInChildren <ClickableObject>()) { CO.PlaceableObject = this; } } gameObject.transform.position = this.Pos; gameObject.transform.LookAt(LookAt); Rot = gameObject.transform.rotation; Scale = scale; if (PlayerManager.Type != "BuilderPlayer") { DisableClickColliders(); } aSceneryComponent ss = gameObject.GetComponentInChildren <aSceneryComponent>(); if (ss != null) { ss.Init(this); } }