private void FindTouchView() { for (int i = 0; i < m_tags.Length; ++i) { Color clr = m_meshColor[i]; clr.a = m_meshAlpha; GUI.backgroundColor = clr; GameObject[] table = GameObject.FindGameObjectsWithTag(m_tags[i]); foreach (GameObject obj in table) { if (obj.GetComponent <XNavObstacleViewFlagment>() == null) { TouchView <NavMeshObstacle>(obj, (sc) => { switch (sc.shape) { case NavMeshObstacleShape.Box: GameObject unitBox = XFunctions.InstanceChild(m_viewUnitBox, Vector3.zero, Quaternion.identity, obj); unitBox.GetComponent <XNavObstacleViewUnitBox>().Initialize(this, m_meshColor[i]); break; case NavMeshObstacleShape.Capsule: GameObject unitCapsule = XFunctions.InstanceChild(m_viewUnitCapsule, Vector3.zero, Quaternion.identity, obj); unitCapsule.GetComponent <XNavObstacleViewUnitCapsule>().Initialize(this, m_meshColor[i]); break; } }); obj.AddComponent <XNavObstacleViewFlagment>(); } } } }
// Awake is called when the script instance is being loaded. void Awake() { m_pool = this.transform.FindChild("SEPool"); XLogger.LogValidObject(m_pool, LibConstants.ErrorMsg.GetMsgNotFoundObject("SEPool"), gameObject); // Instance Pool for (int i = 0; i < m_startInstance; ++i) { XFunctions.InstanceChild(m_unit, Vector3.zero, Quaternion.identity, m_pool.gameObject); } }
private GameObject AllocPlayerUnit(Vector3 position, Quaternion rotate) { if (m_pool.childCount > 0) { GameObject obj = m_pool.GetChild(0).gameObject; obj.transform.parent = this.transform; obj.transform.position = position; obj.transform.rotation = rotate; return(obj); } else { return(XFunctions.InstanceChild(m_unit, position, rotate, gameObject)); } }
private void FindTouchView() { for (int i = 0; i < m_tags.Length; ++i) { Color clr = m_meshColor[i]; clr.a = m_meshAlpha; GUI.backgroundColor = clr; GameObject[] table = GameObject.FindGameObjectsWithTag(m_tags[i]); foreach (GameObject obj in table) { if (obj.GetComponent <XCollisionViewFlagment>() == null) { TouchView <SphereCollider>(obj, (sc) => { GameObject unit = XFunctions.InstanceChild(m_viewUnitSphere, Vector3.zero, Quaternion.identity, obj); unit.GetComponent <XCollisionViewUnitSphere>().Initialize(this, m_meshColor[i]); }); TouchView <BoxCollider>(obj, (sc) => { GameObject unit = XFunctions.InstanceChild(m_viewUnitBox, Vector3.zero, Quaternion.identity, obj); unit.GetComponent <XCollisionViewUnitBox>().Initialize(this, m_meshColor[i]); }); TouchView <CapsuleCollider>(obj, (sc) => { GameObject unit = XFunctions.InstanceChild(m_viewUnitCapsule, Vector3.zero, Quaternion.identity, obj); unit.GetComponent <XCollisionViewUnitCapsule>().Initialize(this, m_meshColor[i]); }); obj.AddComponent <XCollisionViewFlagment>(); } } } }