public override void Build() { if (m_SerialId == 0) { if (Application.isPlaying) { TransformParam param = new TransformParam(); param.Position = transform.position; param.EulerAngles = transform.rotation.eulerAngles; param.Scale = transform.localScale; m_SerialId = GameEntry.Level.CreateLevelObject(Constant.Define.Portal, param); } else { #if UNITY_EDITOR GameObject portal = LevelComponent.CreateLevelEditorObject(MapHolderType.Portal); portal.transform.parent = transform; portal.transform.localPosition = Vector3.zero; portal.transform.localEulerAngles = Vector3.zero; portal.transform.localScale = Vector3.one; #endif } } }
public override void Build() { if (Width < m_DefaultWidth) { Width = m_DefaultWidth; } int count = Mathf.CeilToInt(Width / m_DefaultWidth); m_Size.x = count * m_DefaultWidth; m_Size.y = 4; m_Size.z = 1.5f; m_Body = transform.Find("Body"); if (m_Body == null) { m_Body = new GameObject("Body").transform; m_Body.parent = transform; m_Body.transform.localPosition = Vector3.zero; m_Body.localEulerAngles = Vector3.zero; } else { m_Body.DestroyChildren(); } float halfCount = count * 0.5f; for (int i = 0; i < count; i++) { if (Application.isPlaying) { TransformParam param = new TransformParam(); param.Position = transform.position; param.EulerAngles = transform.rotation.eulerAngles; param.Scale = transform.localScale; m_SerialId = GameEntry.Level.CreateLevelObject(Constant.Define.Barrier, param); } else { #if UNITY_EDITOR GameObject barrier = LevelComponent.CreateLevelEditorObject(MapHolderType.Barrier); barrier.transform.parent = transform; Vector3 localPosition = Vector3.right * (i - halfCount + 0.5f) * m_DefaultWidth; localPosition.z = m_Size.z * 0.5f; barrier.transform.localPosition = localPosition; barrier.transform.localEulerAngles = Vector3.zero; barrier.transform.localScale = Vector3.one; #endif } } m_Collider = gameObject.GetOrAddComponent <BoxCollider>(); m_Collider.size = m_Size; m_Collider.center = new Vector3(0, m_Size.y * 0.5f, m_Size.z * 0.5f); GlobalTools.SetLayer(gameObject, Constant.Layer.BarrerId); }
public override void Build() { transform.DestroyChildren(); if (Application.isPlaying) { TransformParam param = new TransformParam(); param.Position = transform.position; param.EulerAngles = transform.rotation.eulerAngles; param.Scale = transform.localScale; m_SerialId = GameEntry.Level.CreateLevelObject(Id, param); } else { #if UNITY_EDITOR GameObject mine = LevelComponent.CreateLevelEditorObject(MapHolderType.MineGroup); mine.transform.SetParent(transform, false); mine.transform.localPosition = Vector3.zero; mine.transform.localScale = Vector3.one; mine.transform.localRotation = Quaternion.identity; #endif } }