示例#1
0
        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();
        }
示例#2
0
        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;
                        }
                    }
                }
            }
        }