public override void Setup() { base.Setup(); U.Object.Instantiate(m_ContentPrefab, m_WorkspaceUI.sceneContainer, false); m_ChessboardUI = GetComponentInChildren <ChessboardUI>(); m_GridMaterial = U.Material.GetMaterialClone(m_ChessboardUI.grid); // Set up MiniWorld m_MiniWorld = GetComponentInChildren <MiniWorld>(); m_MiniWorld.referenceTransform.position = Vector3.up * kInitReferenceYOffset * kInitReferenceScale; m_MiniWorld.referenceTransform.localScale = Vector3.one * kInitReferenceScale; // Set up ControlBox var panZoomHandle = m_ChessboardUI.panZoomHandle; // ControlBox shouldn't move with miniWorld panZoomHandle.transform.parent = m_WorkspaceUI.sceneContainer; panZoomHandle.transform.localPosition = Vector3.down * panZoomHandle.transform.localScale.y * 0.5f; panZoomHandle.dragStarted += OnControlDragStarted; panZoomHandle.dragging += OnControlDragging; panZoomHandle.dragEnded += OnControlDragEnded; panZoomHandle.hoverStarted += OnControlHoverStarted; panZoomHandle.hoverEnded += OnControlHoverEnded; // Set up UI var UI = U.Object.Instantiate(m_UIPrefab, m_WorkspaceUI.frontPanel, false); m_ZoomSliderUI = UI.GetComponentInChildren <ZoomSliderUI>(); m_ZoomSliderUI.sliding += OnSliding; m_ZoomSliderUI.zoomSlider.maxValue = kMaxScale; m_ZoomSliderUI.zoomSlider.minValue = kMinScale; m_ZoomSliderUI.zoomSlider.value = kInitReferenceScale; // Propagate initial bounds OnBoundsChanged(); }
public override void Setup() { // Initial bounds must be set before the base.Setup() is called minBounds = new Vector3(kMinBounds.x, kMinBounds.y, 0.25f); m_CustomStartingBounds = new Vector3(kMinBounds.x, kMinBounds.y, 0.5f); base.Setup(); U.Object.Instantiate(m_ContentPrefab, m_WorkspaceUI.sceneContainer, false); m_MiniWorldUI = GetComponentInChildren <MiniWorldUI>(); m_GridMaterial = U.Material.GetMaterialClone(m_MiniWorldUI.grid); var resetUI = U.Object.Instantiate(m_RecenterUIPrefab, m_WorkspaceUI.frontPanel, false).GetComponentInChildren <ResetUI>(); resetUI.resetButton.onClick.AddListener(ResetChessboard); foreach (var mb in resetUI.GetComponentsInChildren <MonoBehaviour>()) { connectInterfaces(mb); } var parent = m_WorkspaceUI.frontPanel.parent; var locatePlayerUI = U.Object.Instantiate(m_LocatePlayerPrefab, parent, false); m_PlayerDirectionButton = locatePlayerUI.transform.GetChild(0); foreach (var mb in locatePlayerUI.GetComponentsInChildren <MonoBehaviour>()) { var button = mb as Button; if (button) { button.onClick.AddListener(RecenterOnPlayer); } } var arrow = U.Object.Instantiate(m_PlayerDirectionArrowPrefab, parent, false); arrow.transform.localPosition = new Vector3(-0.232f, 0.03149995f, 0f); m_PlayerDirectionArrow = arrow.transform; // Set up MiniWorld m_MiniWorld = GetComponentInChildren <MiniWorld>(); m_MiniWorld.referenceTransform.position = Vector3.up * kInitReferenceYOffset * kInitReferenceScale; m_MiniWorld.referenceTransform.localScale = Vector3.one * kInitReferenceScale; // Set up ControlBox var panZoomHandle = m_MiniWorldUI.panZoomHandle; // ControlBox shouldn't move with miniWorld panZoomHandle.transform.parent = m_WorkspaceUI.sceneContainer; panZoomHandle.transform.localPosition = Vector3.down * panZoomHandle.transform.localScale.y * 0.5f; panZoomHandle.dragStarted += OnPanZoomDragStarted; panZoomHandle.dragging += OnPanZoomDragging; panZoomHandle.dragEnded += OnPanZoomDragEnded; panZoomHandle.hoverStarted += OnPanZoomHoverStarted; panZoomHandle.hoverEnded += OnPanZoomHoverEnded; // Set up UI var UI = U.Object.Instantiate(m_UIPrefab, m_WorkspaceUI.frontPanel, false); m_ZoomSliderUI = UI.GetComponentInChildren <ZoomSliderUI>(); m_ZoomSliderUI.sliding += OnSliding; m_ZoomSliderUI.zoomSlider.maxValue = kMaxZoomScale; m_ZoomSliderUI.zoomSlider.minValue = kMinZoomScale; m_ZoomSliderUI.zoomSlider.direction = Slider.Direction.RightToLeft; // Invert direction for expected ux; zoom in as slider moves left to right m_ZoomSliderUI.zoomSlider.value = kInitReferenceScale; foreach (var mb in m_ZoomSliderUI.GetComponentsInChildren <MonoBehaviour>()) { connectInterfaces(mb); } var frontHandle = m_WorkspaceUI.directManipulator.GetComponent <BaseHandle>(); frontHandle.dragStarted += DragStarted; frontHandle.dragEnded += DragEnded; // Propagate initial bounds OnBoundsChanged(); }