Example #1
0
        private void DrawLayerMarker()
        {
            RaycastHit hit;
            Ray        worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
            LayerMask  _mask    = 1 << LayerMask.NameToLayer("EditorLevel");
            VGlobal    vg       = VGlobal.GetSetting();
            bool       isHit    = Physics.Raycast(worldRay, out hit, vg.editDis, _mask);

            if (isHit && hit.collider.GetComponentInParent <Volume> () == volume)
            {
                RaycastHit hitFix = hit;
                WorldPos   pos    = EditTerrain.GetBlockPos(hitFix, false);
                hitFix.point = new Vector3(pos.x * vg.w, pos.y * vg.h, pos.z * vg.d);

                Handles.RectangleCap(0, hitFix.point + new Vector3(0, vg.hh, 0), Quaternion.Euler(90, 0, 0), vg.hw);
                Handles.DrawLine(hit.point, hitFix.point);
                volume.useBox = true;
                BoxCursorUtils.UpdateBox(volume.box, hitFix.point, Vector3.zero);
            }
            else
            {
                volume.useBox = false;
            }
            SceneView.RepaintAll();
        }
Example #2
0
        private void DrawMarker(bool isErase)
        {
            RaycastHit hit;
            Ray        worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
            LayerMask  _mask    = 1 << LayerMask.NameToLayer("Editor");
            VGlobal    vg       = VGlobal.GetSetting();
            bool       isHit    = Physics.Raycast(worldRay, out hit, vg.editDis, _mask);

            if (isHit && !isErase && hit.collider.GetComponentInParent <Volume> () == volume)
            {
                RaycastHit hitFix = hit;
                WorldPos   pos    = EditTerrain.GetBlockPos(hitFix, isErase ? false : true);
                hitFix.point = new Vector3(pos.x * vg.w, pos.y * vg.h, pos.z * vg.d);

                Handles.DrawLine(hit.point, hit.point + hit.normal);
                if (hit.collider.gameObject.tag == PathCollect.rularTag)
                {
                    hit.normal = Vector3.zero;
                }
                BoxCursorUtils.UpdateBox(volume.box, hitFix.point, hit.normal);
                SceneView.RepaintAll();
            }
            else
            {
                volume.useBox = false;
                SceneView.RepaintAll();
            }
        }
Example #3
0
 void CreateBox()
 {
     if (!box)
     {
         VGlobal vg = VGlobal.GetSetting();
         box = BoxCursorUtils.CreateBoxCursor(this.transform, new Vector3(vg.w, vg.h, vg.d));
     }
 }
Example #4
0
        private void DrawGridMarker()
        {
            if (_pieceSelected == null)
            {
                return;
            }
            bool       isNotLayer = (currentEditMode != EditMode.ObjectLayer);
            RaycastHit hit;
            Ray        worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
            LayerMask  _mask    = isNotLayer ? 1 << LayerMask.NameToLayer("Editor") : 1 << LayerMask.NameToLayer("EditorLevel");
            VGlobal    vg       = VGlobal.GetSetting();
            bool       isHit    = Physics.Raycast(worldRay, out hit, (int)vg.editDis, _mask);

            if (isHit && hit.collider.GetComponentInParent <Volume> () == volume)
            {
                if (hit.normal.y <= 0)
                {
                    return;
                }

                RaycastHit hitFix = hit;
                WorldPos   pos    = EditTerrain.GetBlockPos(hitFix, isNotLayer);
                hitFix.point = new Vector3(pos.x * vg.w, pos.y * vg.h, pos.z * vg.d);

                WorldPos gPos = EditTerrain.GetGridPos(hit.point);
                gPos.y = isNotLayer ? 0 : (int)vg.h;

                float gx = pos.x * vg.w + gPos.x + ((pos.x < 0) ? 1 : -1);
                float gy = pos.y * vg.h + gPos.y - vg.hh;
                float gz = pos.z * vg.d + gPos.z + ((pos.z < 0) ? 1 : -1);

                LevelPiece.PivotType pivot = _pieceSelected.pivot;
                if (CheckPlaceable((int)gPos.x, (int)gPos.z, pivot))
                {
                    Handles.color = Color.red;
                    Handles.RectangleCap(0, new Vector3(gx, gy, gz), Quaternion.Euler(90, 0, 0), 0.5f);
                    Handles.color = Color.white;
                }

                Handles.color    = Color.white;
                Handles.lighting = true;
                Handles.RectangleCap(0, hitFix.point - new Vector3(0, vg.hh - gPos.y, 0), Quaternion.Euler(90, 0, 0), vg.hw);
                Handles.DrawLine(hit.point, hitFix.point);

                volume.useBox = true;
                BoxCursorUtils.UpdateBox(volume.box, hitFix.point, Vector3.zero);
                SceneView.RepaintAll();
            }
            else
            {
                volume.useBox = false;
                SceneView.RepaintAll();
            }
        }