Beispiel #1
0
            public DragState(WorkspaceUI workspaceUI, Transform rayOrigin, bool resizing)
            {
                m_WorkspaceUI  = workspaceUI;
                m_Resizing     = resizing;
                this.rayOrigin = rayOrigin;

                if (resizing)
                {
                    var pointerPosition = m_WorkspaceUI.GetPointerPosition(rayOrigin);
                    m_DragStart       = pointerPosition;
                    m_PositionStart   = workspaceUI.transform.parent.position;
                    m_BoundsSizeStart = workspaceUI.bounds.size;
                    var localPosition = m_WorkspaceUI.transform.InverseTransformPoint(pointerPosition);
                    m_Direction = m_WorkspaceUI.GetResizeDirectionForLocalPosition(localPosition);
                }
                else
                {
                    MathUtilsExt.GetTransformOffset(rayOrigin, m_WorkspaceUI.transform.parent, out m_PositionOffset, out m_RotationOffset);
                }
            }
Beispiel #2
0
        public virtual void Setup()
        {
            var baseObject = this.InstantiateUI(m_BasePrefab, transform, false);

            m_WorkspaceUI = baseObject.GetComponent <WorkspaceUI>();
            this.ConnectInterfaces(m_WorkspaceUI);
            this.InjectFunctionalitySingle(m_WorkspaceUI);
            m_WorkspaceUI.closeClicked     += OnCloseClicked;
            m_WorkspaceUI.resetSizeClicked += OnResetClicked;
            m_WorkspaceUI.buttonHovered    += OnButtonHovered;
            m_WorkspaceUI.hoveringFrame    += OnHoveringFrame;
            m_WorkspaceUI.moving           += OnMoving;
            m_WorkspaceUI.resizing         += OnResizing;

            m_WorkspaceUI.leftRayOrigin  = leftRayOrigin;
            m_WorkspaceUI.rightRayOrigin = rightRayOrigin;

            m_WorkspaceUI.resize += bounds =>
            {
                var size       = contentBounds.size;
                var boundsSize = bounds.size;
                size.x = boundsSize.x;
                size.z = boundsSize.z;
                var content = contentBounds;
                content.size  = size;
                contentBounds = content;
            };

            m_WorkspaceUI.sceneContainer.transform.localPosition = Vector3.zero;

            m_OuterCollider           = gameObject.AddComponent <BoxCollider>();
            m_OuterCollider.isTrigger = true;

            var startingBounds = m_CustomStartingBounds ?? DefaultBounds;

            //Do not set bounds directly, in case OnBoundsChanged requires Setup override to complete
            m_ContentBounds = new Bounds(startingBounds.y * 0.5f * Vector3.up, startingBounds); // If custom bounds have been set, use them as the initial bounds
            UpdateBounds();

            this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateShow());
        }