Exemple #1
0
        private void Awake()
        {
            filletPanel           = transform.GetChild(0).GetComponent <FilletPanel>();
            boxPanelGraphic       = transform.GetChild(1).GetComponent <LeapBoxGraphic>();
            panelGraphic          = transform.GetChild(2).GetComponent <LeapPanelGraphic>();
            panelOutlineGraphic   = transform.GetChild(3).GetComponent <LeapPanelOutlineGraphic>();
            panelCollider         = transform.GetChild(4).GetComponent <BoxCollider>();
            rendererSpaceCollider = GetComponent <BoxCollider>();

            surfaceUniformColorZone  = panelCollider.GetComponent <UniformColorZone>();
            surfaceGradientColorZone = panelCollider.GetComponent <GradientColorZone>();

            #region Handles
            allHandles       = GetComponentsInChildren <PanelHandle>(true);
            upperHandle      = allHandles.First(item => item.Type == PanelHandle.HandleType.UpperRail);
            lowerHandle      = allHandles.First(item => item.Type == PanelHandle.HandleType.LowerRail);
            leftHandle       = allHandles.First(item => item.Type == PanelHandle.HandleType.LeftRail);
            rightHandle      = allHandles.First(item => item.Type == PanelHandle.HandleType.RightRail);
            upperLeftHandle  = allHandles.First(item => item.Type == PanelHandle.HandleType.UpperLeftCorner);
            lowerLeftHandle  = allHandles.First(item => item.Type == PanelHandle.HandleType.LowerLeftCorner);
            upperRightHandle = allHandles.First(item => item.Type == PanelHandle.HandleType.UpperRightCorner);
            lowerRightHandle = allHandles.First(item => item.Type == PanelHandle.HandleType.LowerRightCorner);
            #endregion

            #region Border Colliders
            borderUpperCollider = outlineColorZone.transform.GetChild(0).GetComponent <BoxCollider>();
            borderLowerCollider = outlineColorZone.transform.GetChild(1).GetComponent <BoxCollider>();
            borderLeftCollider  = outlineColorZone.transform.GetChild(2).GetComponent <BoxCollider>();
            borderRightCollider = outlineColorZone.transform.GetChild(3).GetComponent <BoxCollider>();
            #endregion
        }
Exemple #2
0
        private void Handle_OnHandleGrasped(PanelHandle handle)
        {
            // disable grasping for all the handles that aren't grasped
            foreach (PanelHandle currentHandle in allHandles)
            {
                if (currentHandle != handle)
                {
                    currentHandle.SetGrabbable(false);
                }
            }

            isResizing = true;
        }
Exemple #3
0
        private void Handle_OnhandleUngrasped(PanelHandle handle)
        {
            handle.transform.position = GetPositionForHandle(handle.Type);
            // enable grasping for all the handles
            foreach (PanelHandle currentHandle in allHandles)
            {
                if (currentHandle != handle)
                {
                    currentHandle.SetGrabbable(true);
                }
            }

            isResizing = false;
        }
Exemple #4
0
        public void SetDimensionsForPanel(PanelHandle handle)
        {
            Vector3 handleLocalPosition = transform.InverseTransformPoint(handle.transform.position);

            bool isCorner = HandleIsCorner(handle.Type);

            Vector2 newDimensions = panelSchema.PanelDimensions * 0.5f;

            switch (handle.Type)
            {
            case PanelHandle.HandleType.UpperRail:
            case PanelHandle.HandleType.LowerRail:
                newDimensions = new Vector2(newDimensions.x, Mathf.Abs(handleLocalPosition.y));
                break;

            case PanelHandle.HandleType.LeftRail:
            case PanelHandle.HandleType.RightRail:
                newDimensions = new Vector2(Mathf.Abs(handleLocalPosition.x), newDimensions.y);
                break;

            case PanelHandle.HandleType.UpperLeftCorner:
            case PanelHandle.HandleType.LowerLeftCorner:
            case PanelHandle.HandleType.UpperRightCorner:
            case PanelHandle.HandleType.LowerRightCorner:
                newDimensions = new Vector2(Mathf.Abs(handleLocalPosition.x),
                                            Mathf.Abs(handleLocalPosition.y));
                break;

            default:
                break;
            }

            newDimensions *= 2;

            bool didConstrain = ShouldPanelConstrain(newDimensions, out newDimensions);

            panelSchema.PanelDimensions = newDimensions;

            switch (panelSchema.PanelType)
            {
            case Schema.PanelType.Square:
                break;

            case Schema.PanelType.Fillet:
                filletPanel.SetDimensions(panelSchema.PanelDimensions);
                break;

            default:
                break;
            }

            panelCollider.size = new Vector3(newDimensions.x, newDimensions.y, panelSchema.Depth);
            SetBorderColliders();

            // for all the other handles, just set their position
            foreach (PanelHandle panelHandle in allHandles)
            {
                if (panelHandle != handle)
                {
                    panelHandle.transform.position = GetPositionForHandle(panelHandle.Type);
                }
            }

            SetSpaceColliderBounds();
        }