public void UpdateWithDelete(Vector3 touchPos) { if (true) { var ray = Camera.main.ScreenPointToRay(touchPos); #if UNITY_EDITOR Debug.DrawLine(ray.origin, ray.GetPoint(100f), Color.red, 10f); #endif RaycastHit hit; if (Physics.Raycast(ray, out hit, 30000f, mask)) {// hit somethig //hit map object var obj = hit.collider.gameObject.GetComponentFully <MapObjectBase>(); if (obj != null) { CurrentSelectObject = obj.gameObject; } //hit map dec // if (hit.collider.gameObject.GetComponentFully<MapObjectDecorate>() != null) { // CurrentSelectObject = hit.collider.gameObject; } // Debug.LogError("hit " + hit.collider.gameObject.name); if (CurrentSelectObject != null) { this.CurrentSelectWeapon = CurrentSelectObject.GetComponentFully <MapObjectWeaponSpawnPoint>(); } } } if (CurrentSelectObject != null) { var type = CurrentSelectObject.GetComponent <MapObjectBase>(); if ((type as MapObjectSpawnPoint == null) && (type as MapObjectWeaponSpawnPoint == null)) {// hit spasm will ignore // GameObject.DestroyImmediate(CurrentSelectObject); // MapObjectRoot.ins.DestroyObjectImmediate(CurrentSelectObject); MapObjectRoot.ins.PlayClickEffect(CurrentSelectObject.transform.position); CurrentSelectObject.SetActive(false); MapObjectRoot.ins.DeleteCheckDecrate(CurrentSelectObject); EditorRuntime.Delete(CurrentSelectObject); MapEditorUIMgr.ins.GetPanel <UIPanelMapEditor>().RefreshUndoBtnState(); } MapObjectRoot.ins.CheckAllConflict(); CurrentSelectObject = null; //cancle // root._panel_up.OnBtnDeleteClick(); return; } CurrentSelectObject = null; ClearSelectObject(); }
//编辑器下允许连续 增加物件 void UpdateWithAdded() { if (!IsTouchUI._IsTouchUI && this.GetTouchDown()) { var ray = Camera.main.ScreenPointToRay(this.GetTouchPosition()); RaycastHit hit; if (Physics.Raycast(ray, out hit, 1000f, mask)) {// hit somethig if (CurrentSelectObject != null) { CurrentSelectObject.GetComponentFully <MapObjectBase>().SetBright(false); } if (hit.collider.gameObject.GetComponentFully <MapObjectBase>() != null) { CurrentSelectObject = hit.collider.gameObject.GetComponentFully <MapObjectBase>().gameObject; } /* if (hit.collider.gameObject.GetComponentFully<MapObjectDecorate>() != null) * { * CurrentSelectObject = hit.collider.gameObject; * }*/ _position_delta = hit.collider.gameObject.GetComponentFully <MapObjectBase>().gameObject.transform.position - Camera.main.ScreenToWorldPoint(this.GetTouchPosition()); pos_begin_touch = hit.collider.gameObject.GetComponentFully <MapObjectBase>().gameObject.transform.position; // Debug.LogError("hit " + hit.collider.gameObject.name + " " + CurrentSelectObject.gameObject.name); this.CurrentSelectWeapon = CurrentSelectObject.GetComponent <MapObjectWeaponSpawnPoint>(); if (this.CurrentSelectWeapon != null) {//sync view root._panel_up.Sync(this.CurrentSelectWeapon); foreach (var p in CurrentSelectObject.transform.parent.GetComponentsInChildren <MapObjectWeaponSpawnPoint>()) { p.transform.GetChild(0).gameObject.SetActive(false); } CurrentSelectWeapon.transform.GetChild(0).gameObject.SetActive(true); MapObjectRoot.ins.CheckAllConflict(); if (UITips.ins != null) { int order = CurrentSelectWeapon.GetComponent <MapObjectWeaponSpawnPoint>().Order; if (order > 0) { UITips.ins.ShowTips("您正在设置武器" + order + "出生点枪支,请点击顶部枪械设置。"); } else { UITips.ins.ShowTips("您正在设置武器出生点枪支,请点击顶部枪械设置。"); } } } } else { this.CurrentSelectWeapon = null;// if hit nothing will cancel weapon spawn point select status if (CurrentSelectObject != null) { CurrentSelectObject.GetComponent <MapObjectBase>().SetBright(false); } // not hit some thind - if select then added int currentSelectId = 0; if (_panel_up.currentSelect != null) { currentSelectId = _panel_up.currentSelect.id; } else if (_panel_level_two.currentSelect != null) { currentSelectId = _panel_level_two.currentSelect.id; } if (currentSelectId > 0) { if (MapObjectRoot.ins.TotalMapObjectCount > MAX_NUM) { if (UICommonDialog.ins != null) { UICommonDialog.ins.ShowOK("数量达到上限"); } } else { // if (root.CurrentStep == MapEditorStep.MapObject) { /////////////////////////////////////////////// //点击空地时创建 var obj = MapObjectRoot.ins.CreateObject(currentSelectId.ToString(), LayerMgr.ins.GetCurLayerTransform()); var pos = Camera.main.ScreenToWorldPoint(this.GetTouchPosition()); pos.x = 0f; // Debug.LogError(pos); obj.transform.position = pos; CurrentSelectObject = obj; //计算包围盒 boundingBox = CurrentSelectObject.CalculateBounds(); _position_delta = Vector3.zero; // create one will cancel selected root._panel_up.ClearSelected(); root._panel_left.ClearSelected(); return; } } } } } var tmpcurrent = CurrentSelectObject; if (this.GetTouchUp()) { this.CurrentSelectWeapon = null;// if hit nothing will cancel weapon spawn point select status if (CurrentSelectObject != null && (CurrentSelectObject.GetComponent <MapObject>() != null || CurrentSelectObject.GetComponent <MapObjectDecorate>() != null)) { if (MapObjectRoot.ins.CheckConflict(CurrentSelectObject)) { CurrentSelectObject.transform.position = pos_begin_touch; } CurrentSelectObject.GetComponent <MapObjectBase>().SetBright(false); MapObjectRoot.ins.CheckAllConflict(); //编辑器模式下 允许连续点击物件 鼠标右键取消 var obj = MapObjectRoot.ins.CreateObject(CurrentSelectObject.name, LayerMgr.ins.GetCurLayerTransform()); var pos = Camera.main.ScreenToWorldPoint(this.GetTouchPosition()); pos.x = 0f; // Debug.LogError(pos); obj.transform.position = pos; CurrentSelectObject = obj; _position_delta = Vector3.zero; // create one will cancel selected root._panel_up.ClearSelected(); root._panel_left.ClearSelected(); return; } else { if (CurrentSelectObject != null) { if (MapObjectRoot.ins.CheckConflict(CurrentSelectObject)) { CurrentSelectObject.transform.position = pos_begin_touch; } CurrentSelectObject.GetComponent <MapObjectBase>().SetBright(false); MapObjectRoot.ins.CheckAllConflict(); } CurrentSelectObject = null; } } if (Input.GetMouseButtonDown(1) && CurrentSelectObject != null && (CurrentSelectObject.GetComponent <MapObject>() != null || CurrentSelectObject.GetComponent <MapObjectDecorate>() != null)) { MapObjectRoot.ins.DestroyObjectImmediate(CurrentSelectObject); CurrentSelectObject = null; root.touchBehaviour = TouchBehaviour.Select; return; } if (CurrentSelectObject != null) { var pos_pre = CurrentSelectObject.transform.position; var pos = Camera.main.ScreenToWorldPoint(this.GetTouchPosition()) + _position_delta; pos.x = 0f; CurrentSelectObject.transform.position = pos; if (MapObjectRoot.ins.CheckConflict(CurrentSelectObject)) { MapObjectRoot.ins.SetBrightAll(true); CurrentSelectObject.GetComponent <MapObjectBase>().SetBright(true); } else { MapObjectRoot.ins.SetBrightAll(false); } //move if (CurrentSelectObject.transform.hasChanged) { // MapObjectRoot.ins.CheckAllConflict(); CurrentSelectObject.transform.hasChanged = false; } } // CurrentSelectObject = tmpcurrent; if (Input.GetMouseButtonDown(1)) { // CurrentSelectObject = null; } //拖动连续生成 if (isTouchDown && !IsTouchUI._IsTouchUI) { if (CurrentSelectObject != null) { if (MapObjectRoot.ins.TotalMapObjectCount > MAX_NUM) { if (UICommonDialog.ins != null) { UICommonDialog.ins.ShowOK("数量达到上限"); } } else { var pos = Camera.main.ScreenToWorldPoint(this.GetTouchPosition()); pos.x = 0f; if (boundingBox != null) { //离上个物体足够距离了 if ((Mathf.Abs(boundingBox.center.y - pos.y) >= boundingBox.size.y) || (Mathf.Abs(boundingBox.center.z - pos.z) >= boundingBox.size.z)) { var obj = MapObjectRoot.ins.CreateObject(CurrentSelectObject.name, LayerMgr.ins.GetCurLayerTransform()); obj.transform.position = pos; CurrentSelectObject = obj; boundingBox.center = pos; return; } } } } } }
void UpdateWithDelete() { if (this.GetTouchDown() && !IsTouchUI._IsTouchUI) { var ray = Camera.main.ScreenPointToRay(this.GetTouchPosition()); #if UNITY_EDITOR Debug.DrawLine(ray.origin, ray.GetPoint(100f), Color.red, 10f); #endif RaycastHit hit; if (Physics.Raycast(ray, out hit, 1000f, mask)) {// hit somethig //hit map object var obj = hit.collider.gameObject.GetComponentFully <MapObjectBase>(); if (obj != null) { CurrentSelectObject = obj.gameObject; } //hit map dec // if (hit.collider.gameObject.GetComponentFully<MapObjectDecorate>() != null) { // CurrentSelectObject = hit.collider.gameObject; } // Debug.LogError("hit " + hit.collider.gameObject.name); if (CurrentSelectObject != null) { this.CurrentSelectWeapon = CurrentSelectObject.GetComponentFully <MapObjectWeaponSpawnPoint>(); } } else { this.CurrentSelectWeapon = null;// if hit nothing will cancel weapon spawn point select status if (_panel_up.currentSelect != null) { var obj = MapObjectRoot.ins.CreateObject(_panel_up.currentSelect.id.ToString(), LayerMgr.ins.GetCurLayerTransform()); var pos = Camera.main.ScreenToWorldPoint(this.GetTouchPosition()); pos.x = 0f; // Debug.LogError(pos); obj.transform.position = pos; CurrentSelectObject = obj; // create one will cancel selected root._panel_up.ClearSelected(); root._panel_left.ClearSelected(); } } #if UNITY_EDITOR //编辑器模式,不需要取消删除按钮的点击 #else //root._panel_up.OnBtnDeleteClick(); #endif } if (CurrentSelectObject != null) { var type = CurrentSelectObject.GetComponent <MapObjectBase>(); if ((type as MapObjectSpawnPoint == null) && (type as MapObjectWeaponSpawnPoint == null)) {// hit spasm will ignore // GameObject.DestroyImmediate(CurrentSelectObject); // MapObjectRoot.ins.DestroyObjectImmediate(CurrentSelectObject); EditorRuntime.Delete(CurrentSelectObject); } MapObjectRoot.ins.CheckAllConflict(); CurrentSelectObject = null; //cancle // root._panel_up.OnBtnDeleteClick(); return; } CurrentSelectObject = null; ClearSelectObject(); //拖动连续删除 if (isTouchDown && !IsTouchUI._IsTouchUI) { var ray = Camera.main.ScreenPointToRay(this.GetTouchPosition()); RaycastHit hit; if (Physics.Raycast(ray, out hit, 1000f, mask)) { var obj = hit.collider.gameObject.GetComponentFully <MapObjectBase>(); if (obj != null) { CurrentSelectObject = obj.gameObject; if (CurrentSelectObject != null) { var type = CurrentSelectObject.GetComponent <MapObjectBase>(); if ((type as MapObjectSpawnPoint == null) && (type as MapObjectWeaponSpawnPoint == null)) { EditorRuntime.Delete(CurrentSelectObject); } MapObjectRoot.ins.CheckAllConflict(); CurrentSelectObject = null; //cancle // root._panel_up.OnBtnDeleteClick(); return; } } } } }
void UpdateWithAdded() { if (!IsTouchUI._IsTouchUI && this.GetTouchDown()) { var ray = Camera.main.ScreenPointToRay(this.GetTouchPosition()); #if UNITY_EDITOR Debug.DrawLine(ray.origin, ray.GetPoint(100f), Color.red, 10f); #endif RaycastHit hit; if (Physics.Raycast(ray, out hit, 1000f, mask)) {// hit somethig if (CurrentSelectObject != null) { CurrentSelectObject.GetComponentFully <MapObjectBase>().SetBright(false); } if (hit.collider.gameObject.GetComponentFully <MapObjectBase>() != null) { CurrentSelectObject = hit.collider.gameObject.GetComponentFully <MapObjectBase>().gameObject; } /* if (hit.collider.gameObject.GetComponentFully<MapObjectDecorate>() != null) * { * CurrentSelectObject = hit.collider.gameObject; * }*/ _position_delta = hit.collider.gameObject.GetComponentFully <MapObjectBase>().gameObject.transform.position - Camera.main.ScreenToWorldPoint(this.GetTouchPosition()); pos_begin_touch = hit.collider.gameObject.GetComponentFully <MapObjectBase>().gameObject.transform.position; // Debug.LogError("hit " + hit.collider.gameObject.name + " " + CurrentSelectObject.gameObject.name); this.CurrentSelectWeapon = CurrentSelectObject.GetComponent <MapObjectWeaponSpawnPoint>(); if (this.CurrentSelectWeapon != null) {//sync view root._panel_up.Sync(this.CurrentSelectWeapon); foreach (var p in CurrentSelectObject.transform.parent.GetComponentsInChildren <MapObjectWeaponSpawnPoint>()) { p.transform.GetChild(0).gameObject.SetActive(false); } CurrentSelectWeapon.transform.GetChild(0).gameObject.SetActive(true); MapObjectRoot.ins.CheckAllConflict(); if (UITips.ins != null) { int order = CurrentSelectWeapon.GetComponent <MapObjectWeaponSpawnPoint>().Order; if (order > 0) { UITips.ins.ShowTips("您正在设置武器" + order + "出生点枪支,请点击顶部枪械设置。"); } else { UITips.ins.ShowTips("您正在设置武器出生点枪支,请点击顶部枪械设置。"); } } } else if (CurrentSelectObject != null)//点中的是之前的物件(直接切换到选择模式) { var type = CurrentSelectObject.GetComponent <MapObjectBase>(); if ((type as MapObjectSpawnPoint == null) && (type as MapObjectWeaponSpawnPoint == null)) { root.touchBehaviour = TouchBehaviour.Select; SelectObject(CurrentSelectObject); } } } else { this.CurrentSelectWeapon = null;// if hit nothing will cancel weapon spawn point select status if (CurrentSelectObject != null) { CurrentSelectObject.GetComponent <MapObjectBase>().SetBright(false); } // not hit some thind - if select then added int currentSelectId = 0; if (_panel_up.currentSelect != null) { currentSelectId = _panel_up.currentSelect.id; } else if (_panel_level_two.currentSelect != null) { currentSelectId = _panel_level_two.currentSelect.id; } if (currentSelectId > 0) { #if UNITY_EDITOR if (MapObjectRoot.ins.TotalMapObjectCount > MAX_NUM) #else //#1000170 改为不限制碰撞和增加物件上限为50 if (MapObjectRoot.ins.TotalMapObjectCount > DevConfig.MapEditorMaxAllowMapObjectNumber) #endif { if (UICommonDialog.ins != null) { UICommonDialog.ins.ShowOK("数量达到上限"); } } else { // if (root.CurrentStep == MapEditorStep.MapObject) { var obj = MapObjectRoot.ins.CreateObject(currentSelectId.ToString()); var pos = Camera.main.ScreenToWorldPoint(this.GetTouchPosition()); pos.x = 0f; // Debug.LogError(pos); obj.transform.position = pos; CurrentSelectObject = obj; boundingBox = obj.CalculateBounds(); _position_delta = Vector3.zero; // create one will cancel selected //root._panel_up.ClearSelected(); //root._panel_left.ClearSelected(); return; } } } else //没生成又没碰到组件 { ClearSelectObject(); } } } if (this.GetTouchUp()) { this.CurrentSelectWeapon = null;// if hit nothing will cancel weapon spawn point select status //if (CurrentSelectObject != null) //{ // if (MapObjectRoot.ins.CheckConflict(CurrentSelectObject)) // { // CurrentSelectObject.transform.position = pos_begin_touch; // } // CurrentSelectObject.GetComponent<MapObjectBase>().SetBright(false); // MapObjectRoot.ins.CheckAllConflict(); //} CurrentSelectObject = null; } //当前鼠标控制武器人物出生点移动 if (CurrentSelectObject != null) { var type = CurrentSelectObject.GetComponent <MapObjectBase>(); if ((type as MapObjectSpawnPoint != null) || (type as MapObjectWeaponSpawnPoint != null)) { var pos_pre = CurrentSelectObject.transform.position; var pos = Camera.main.ScreenToWorldPoint(this.GetTouchPosition()) + _position_delta; pos.x = 0f; CurrentSelectObject.transform.position = pos; if (MapObjectRoot.ins.CheckConflict(CurrentSelectObject)) { MapObjectRoot.ins.SetBrightAll(true); CurrentSelectObject.GetComponent <MapObjectBase>().SetBright(true); } else { MapObjectRoot.ins.SetBrightAll(false); } //move if (CurrentSelectObject.transform.hasChanged) { // MapObjectRoot.ins.CheckAllConflict(); CurrentSelectObject.transform.hasChanged = false; } } } //拖动连续生成 if (Input.touchCount > 0) { UnityEngine.Touch th = Input.GetTouch(0); if ((th.phase == TouchPhase.Moved) && !IsTouchUI._IsTouchUI) { if (CurrentSelectObject != null) { if (MapObjectRoot.ins.TotalMapObjectCount > MAX_NUM) { if (UICommonDialog.ins != null) { UICommonDialog.ins.ShowOK("数量达到上限"); } } else { var pos = Camera.main.ScreenToWorldPoint(this.GetTouchPosition()); pos.x = 0f; if (boundingBox != null) { //离上个物体足够距离了 if ((Mathf.Abs(boundingBox.center.y - pos.y) >= boundingBox.size.y) || (Mathf.Abs(boundingBox.center.z - pos.z) >= boundingBox.size.z)) { var obj = MapObjectRoot.ins.CreateObject(CurrentSelectObject.name, LayerMgr.ins.GetCurLayerTransform()); obj.transform.position = pos; CurrentSelectObject = obj; boundingBox.center = pos; return; } } } } } } }
//编辑器下允许连续 增加物件 public void UpdateWithAdded(Vector3 touchPos) { if (true) { var ray = Camera.main.ScreenPointToRay(touchPos); RaycastHit hit; if (Physics.Raycast(ray, out hit, 30000f, mask)) {// hit somethig if (CurrentSelectObject != null) { CurrentSelectObject.GetComponentFully <MapObjectBase>().SetBright(false); } if (hit.collider.gameObject.GetComponentFully <MapObjectBase>() != null) { CurrentSelectObject = hit.collider.gameObject.GetComponentFully <MapObjectBase>().gameObject; //如果选中普通的组件,开始计时长按 if ((CurrentSelectObject.GetComponent <MapObjectWeaponSpawnPoint>() == null) && (CurrentSelectObject.GetComponent <MapObjectSpawnPoint>() == null)) { this.BeginMapObjectPressed(); } } /* if (hit.collider.gameObject.GetComponentFully<MapObjectDecorate>() != null) * { * CurrentSelectObject = hit.collider.gameObject; * }*/ _position_delta = hit.collider.gameObject.GetComponentFully <MapObjectBase>().gameObject.transform.position - Camera.main.ScreenToWorldPoint(touchPos); pos_begin_touch = hit.collider.gameObject.GetComponentFully <MapObjectBase>().gameObject.transform.position; // Debug.LogError("hit " + hit.collider.gameObject.name + " " + CurrentSelectObject.gameObject.name); this.CurrentSelectWeapon = CurrentSelectObject.GetComponent <MapObjectWeaponSpawnPoint>(); if (this.CurrentSelectWeapon != null) {//sync view var dlg = MapEditorUIMgr.ins.GetPanel <UIPanelMapEditorDown>(); if (dlg != null) { dlg.Sync(this.CurrentSelectWeapon); } foreach (var p in CurrentSelectObject.transform.parent.GetComponentsInChildren <MapObjectWeaponSpawnPoint>()) { p.transform.GetChild(0).gameObject.SetActive(false); } CurrentSelectWeapon.transform.GetChild(0).gameObject.SetActive(true); MapObjectRoot.ins.CheckAllConflict(); if (UITips.ins != null) { int order = CurrentSelectWeapon.GetComponent <MapObjectWeaponSpawnPoint>().Order; if (order > 0) { UITips.ins.ShowTips("您正在设置武器" + order + "出生点枪支,请点击底部枪械设置。"); } else { UITips.ins.ShowTips("您正在设置武器出生点枪支,请点击底部枪械设置。"); } } } } else { this.CurrentSelectWeapon = null;// if hit nothing will cancel weapon spawn point select status if (CurrentSelectObject != null) { CurrentSelectObject.GetComponent <MapObjectBase>().SetBright(false); } // not hit some thind - if select then added if (this.currentSelectId > 0) { if (!this.IsExceedMaxObjectCount(this.currentSelectId)) { // if (root.CurrentStep == MapEditorStep.MapObject) { /////////////////////////////////////////////// //点击空地时创建 var pos = Camera.main.ScreenToWorldPoint(touchPos); // pos.x = 0f; pos.x = EditorLayerMgr.ins.GetCurLayerTransform().position.x; if (MapObjectRoot.ins.OnPreCreateObject(pos, this.currentSelectId)) { var obj = MapObjectRoot.ins.CreateObjectById(this.currentSelectId, EditorLayerMgr.ins.GetCurLayerTransform()); // Debug.LogError(pos); obj.transform.position = pos; //因组件规格的不一致,层节点X方向20倍的缩放 默认创建后有得组件的localscalX为0.05 有得localscaleZ为0.05, //要得到缩放的效果对应的方向localscale必须归一化(多个方向都必须考虑) Vector3 scale = new Vector3(obj.transform.localScale.x, obj.transform.localScale.y, obj.transform.localScale.z); scale = this.CheckLocslScale(scale); obj.transform.localScale = scale; MapObjectRoot.ins.OnPostCreateObject(obj); MapObjectRoot.ins.PlayClickEffect(obj.transform.position); CurrentSelectObject = obj; //计算包围盒, 有"main"子节点就按main计算,没有就按整个计算 var objMain = CurrentSelectObject.transform.Find("main"); if (objMain != null) { boundingBox = objMain.gameObject.CalculateBounds(); } else { boundingBox = CurrentSelectObject.CalculateBounds(); } } _position_delta = Vector3.zero; return; } } } } } }
//拖动跟随或连续生成 public void OnDragMoveOrAdd(Vector3 touchPos) { var ray = Camera.main.ScreenPointToRay(touchPos); RaycastHit hit; if (Physics.Raycast(ray, out hit, 30000f, mask)) { // hit somethig if (CurrentSelectObject != null) { CurrentSelectObject.GetComponentFully <MapObjectBase>().SetBright(false); } if (hit.collider.gameObject.GetComponentFully <MapObjectBase>() != null) { CurrentSelectObject = hit.collider.gameObject.GetComponentFully <MapObjectBase>().gameObject; } } //拖动连续生成 if ((CurrentSelectObject != null) && (CurrentSelectObject.GetComponent <MapObjectSpawnPoint>() == null) && (CurrentSelectObject.GetComponent <MapObjectWeaponSpawnPoint>() == null)) { if (!this.IsExceedMaxObjectCount(this.currentSelectId)) { var pos = Camera.main.ScreenToWorldPoint(touchPos); //pos.x = 0f; pos.x = EditorLayerMgr.ins.GetCurLayerTransform().position.x; if (boundingBox != null) { //竖直方向超过足够距离 if (Mathf.Abs(boundingBox.center.y - pos.y) >= boundingBox.size.y) { if (pos.y > boundingBox.center.y) { pos.y = boundingBox.center.y + boundingBox.size.y; if (boundingBox.size.y < 1) { pos.y = boundingBox.center.y + 1; } else { pos.y = boundingBox.center.y + boundingBox.size.y; } } else { if (boundingBox.size.y < 1) { pos.y = boundingBox.center.y - 1; } else { pos.y = boundingBox.center.y - boundingBox.size.y; } } if (MapObjectRoot.ins.OnPreCreateObject(pos, this.currentSelectId)) { if (this.currentSelectId > 0) { var obj = MapObjectRoot.ins.CreateObjectById(this.currentSelectId, EditorLayerMgr.ins.GetCurLayerTransform()); obj.transform.position = pos; //因组件规格的不一致,层节点X方向20倍的缩放 默认创建后有得组件的localscalX为0.05 有得localscaleZ为0.05, //要得到缩放的效果对应的方向localscale必须归一化(多个方向都必须考虑) Vector3 scale = new Vector3(obj.transform.localScale.x, obj.transform.localScale.y, obj.transform.localScale.z); scale = this.CheckLocslScale(scale); obj.transform.localScale = scale; MapObjectRoot.ins.OnPostCreateObject(obj); MapObjectRoot.ins.PlayClickEffect(obj.transform.position); CurrentSelectObject = obj; boundingBox.center = obj.transform.position; } } else { boundingBox.center = pos; } } //水平方向超过足够距离 else if (Mathf.Abs(boundingBox.center.z - pos.z) >= boundingBox.size.z) { if (pos.z > boundingBox.center.z) { if (boundingBox.size.z < 1) { pos.z = boundingBox.center.z + 1; } else { pos.z = boundingBox.center.z + boundingBox.size.z; } } else { if (boundingBox.size.z < 1) { pos.z = boundingBox.center.z - 1; } else { pos.z = boundingBox.center.z - boundingBox.size.z; } } if (MapObjectRoot.ins.OnPreCreateObject(pos, this.currentSelectId)) { if (this.currentSelectId > 0) { var obj = MapObjectRoot.ins.CreateObjectById(this.currentSelectId, EditorLayerMgr.ins.GetCurLayerTransform()); obj.transform.position = pos; //因组件规格的不一致,层节点X方向20倍的缩放 默认创建后有得组件的localscalX为0.05 有得localscaleZ为0.05, //要得到缩放的效果对应的方向localscale必须归一化(多个方向都必须考虑) Vector3 scale = new Vector3(obj.transform.localScale.x, obj.transform.localScale.y, obj.transform.localScale.z); scale = this.CheckLocslScale(scale); obj.transform.localScale = scale; MapObjectRoot.ins.OnPostCreateObject(obj); MapObjectRoot.ins.PlayClickEffect(obj.transform.position); CurrentSelectObject = obj; boundingBox.center = obj.transform.position; } } else { boundingBox.center = pos; } } } } } }