public virtual void Setup() { var baseObject = this.InstantiateUI(m_BasePrefab); baseObject.transform.SetParent(transform, false); m_WorkspaceUI = baseObject.GetComponent <WorkspaceUI>(); this.ConnectInterfaces(m_WorkspaceUI); m_WorkspaceUI.closeClicked += OnCloseClicked; m_WorkspaceUI.resetSizeClicked += OnResetClicked; m_WorkspaceUI.leftRayOrigin = leftRayOrigin; m_WorkspaceUI.rightRayOrigin = rightRayOrigin; m_WorkspaceUI.resize += bounds => { contentBounds = bounds; }; m_WorkspaceUI.sceneContainer.transform.localPosition = Vector3.zero; //Do not set bounds directly, in case OnBoundsChanged requires Setup override to complete m_ContentBounds = new Bounds(Vector3.up * DefaultBounds.y * 0.5f, m_CustomStartingBounds ?? DefaultBounds); // If custom bounds have been set, use them as the initial bounds UpdateBounds(); this.StopCoroutine(ref m_VisibilityCoroutine); m_VisibilityCoroutine = StartCoroutine(AnimateShow()); }
public virtual void Setup() { GameObject baseObject = instantiateUI(m_BasePrefab); baseObject.transform.SetParent(transform, false); m_WorkspaceUI = baseObject.GetComponent <WorkspaceUI>(); connectInterfaces(m_WorkspaceUI); m_WorkspaceUI.closeClicked += OnCloseClicked; m_WorkspaceUI.resetSizeClicked += OnResetClicked; m_WorkspaceUI.sceneContainer.transform.localPosition = Vector3.zero; //Do not set bounds directly, in case OnBoundsChanged requires Setup override to complete m_ContentBounds = new Bounds(Vector3.up * k_DefaultBounds.y * 0.5f, m_CustomStartingBounds == null ? k_DefaultBounds : m_CustomStartingBounds.Value); // If custom bounds have been set, use them as the initial bounds UpdateBounds(); //Set up DirectManipulator var directManipulator = m_WorkspaceUI.directManipulator; directManipulator.target = transform; directManipulator.translate = Translate; directManipulator.rotate = Rotate; //Set up the front "move" handle highglight, the move handle is used to translate/rotate the workspace var moveHandle = m_WorkspaceUI.moveHandle; moveHandle.dragStarted += OnMoveHandleDragStarted; moveHandle.dragEnded += OnMoveHandleDragEnded; moveHandle.hoverStarted += OnMoveHandleHoverStarted; moveHandle.hoverEnded += OnMoveHandleHoverEnded; var handles = new [] { m_WorkspaceUI.leftHandle, m_WorkspaceUI.frontHandle, m_WorkspaceUI.backHandle, m_WorkspaceUI.rightHandle }; foreach (var handle in handles) { handle.dragStarted += OnHandleDragStarted; handle.dragging += OnHandleDragging; handle.dragEnded += OnHandleDragEnded; handle.hoverStarted += OnHandleHoverStarted; handle.hoverEnded += OnHandleHoverEnded; } this.StopCoroutine(ref m_VisibilityCoroutine); m_VisibilityCoroutine = StartCoroutine(AnimateShow()); }
public virtual void Setup() { var baseObject = this.InstantiateUI(m_BasePrefab, transform, false); m_WorkspaceUI = baseObject.GetComponent <WorkspaceUI>(); this.ConnectInterfaces(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(Vector3.up * startingBounds.y * 0.5f, startingBounds); // If custom bounds have been set, use them as the initial bounds UpdateBounds(); this.StopCoroutine(ref m_VisibilityCoroutine); m_VisibilityCoroutine = StartCoroutine(AnimateShow()); }
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); } }