示例#1
0
        void PaintBounds()
        {
            if (HaveHeight)
            {
                var camera = Camera.current;

                var localBounds = GetShapeBounds(toGridQuaternion);

                var volume = new Vector3[8];
                BoundsUtilities.GetBoundsVertices(localBounds, volume);

                PaintUtility.RenderBoundsSizes(toGridQuaternion, fromGridQuaternion, camera, volume, Color.white, Color.white, Color.white, true, true, true);
            }
        }
示例#2
0
        void PaintSquare()
        {
            var wireframeColor = ColorSettings.BoundsOutlines;

            if (HaveHeight)
            {
                var camera = Camera.current;

                var localBounds = GetShapeBounds(toGridQuaternion);

                var volume = new Vector3[8];
                BoundsUtilities.GetBoundsVertices(localBounds, volume);

                PaintUtility.DrawDottedLines(Matrix4x4.TRS(Vector3.zero, fromGridQuaternion, Vector3.one), volume, BoundsUtilities.AABBLineIndices, wireframeColor, 4.0f);

                PaintUtility.RenderBoundsSizes(toGridQuaternion, fromGridQuaternion, camera, volume, Color.white, Color.white, Color.white, true, true, true);
            }
        }
        public override bool ValidateDrop(bool inSceneView)
        {
            Reset();
            if (DragAndDrop.objectReferences == null ||
                DragAndDrop.objectReferences.Length == 0)
            {
                dragGameObjects = null;
                return(false);
            }

            dragGameObjects = new List <GameObject>();
            foreach (var obj in DragAndDrop.objectReferences)
            {
                var gameObject = obj as GameObject;
                if (gameObject == null)
                {
                    continue;
                }

                if (gameObject.GetComponentInChildren <Renderer>() == null)
                {
                    continue;
                }

                if (PrefabUtility.GetPrefabType(gameObject) == PrefabType.None)
                {
                    continue;
                }

                if (PrefabUtility.GetPrefabParent(gameObject) == null &&
                    PrefabUtility.GetPrefabObject(gameObject) != null)
                {
                    dragGameObjects.Add(gameObject);
                }
            }
            if (dragGameObjects.Count != 1)
            {
                dragGameObjects = null;
                return(false);
            }

            var dragGameObjectBounds = new AABB();

            dragGameObjectBounds.Reset();
            foreach (var gameObject in dragGameObjects)
            {
                var renderers = gameObject.GetComponentsInChildren <Renderer>();
                if (renderers.Length == 0)
                {
                    continue;
                }
                foreach (var renderer in renderers)
                {
                    var bounds = renderer.bounds;
                    dragGameObjectBounds.Extend(bounds.min);
                    dragGameObjectBounds.Extend(bounds.max);
                }
            }

            if (!dragGameObjectBounds.Valid)
            {
                dragGameObjectBounds.Extend(MathConstants.zeroVector3);
            }

            projectedBounds = new Vector3[8];
            BoundsUtilities.GetBoundsVertices(dragGameObjectBounds, projectedBounds);

            /*
             * var upPlane = new Plane(MathConstants.upVector3, MathConstants.zeroVector3);
             * for (int i = 7; i >= 0; i--)
             * {
             *      projectedBounds[i] = upPlane.Project(projectedBounds[i]);
             *      for (int j = i+1; j < projectedBounds.Length; j++)
             *      {
             *              if (projectedBounds[i] == projectedBounds[j])
             *              {
             *                      ArrayUtility.RemoveAt(ref projectedBounds, j);
             *                      break;
             *              }
             *      }
             * }*/

            haveNoParent = false;
            return(true);
        }