////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public virtual void Build(IHoverboardPanelState pPanelState,
										IHoverboardLayoutState pLayoutState, IBaseItemState pItemState,
										IItemVisualSettings pSettings) {
			vPanelState = pPanelState;
			vLayoutState = pLayoutState;
			vItemState = pItemState;
			vSettings = (ItemVisualSettingsStandard)pSettings;
			vSliderItem = (ISliderItem)vItemState.Item;
			vTicks = new GameObject[vSliderItem.Ticks];

			vWidth = UiItem.Size*vSliderItem.Width;
			vHeight = UiItem.Size*vSliderItem.Height;
			vIsVert = (vHeight > vWidth);
			vGrabW = 1;
			vZeroValue = (0-vSliderItem.RangeMin)/(vSliderItem.RangeMax-vSliderItem.RangeMin);

			gameObject.transform.SetParent(gameObject.transform, false);
			gameObject.transform.localPosition = new Vector3(vWidth/2, 0, vHeight/2f);
			gameObject.transform.localRotation = Quaternion.AngleAxis((vIsVert ? 90 : 0), Vector3.up);

			if ( vIsVert ) { //swap dimensions here + rotate graphics later
				float tempW = vWidth;
				vWidth = vHeight;
				vHeight = tempW;
			}

			vSlideX0 = (vGrabW-vWidth)/2;
			vSlideW = vWidth-vGrabW;

			////

			vHiddenRect = new UiHoverMeshRectBg(gameObject);
			vHiddenRect.UpdateSize(vWidth, vHeight);

			var trackObj = new GameObject("Track");
			trackObj.transform.SetParent(gameObject.transform, false);
			trackObj.transform.localPosition = new Vector3(-vWidth/2, 0, 0);

			vTrack = new UiItemSliderTrackRenderer(trackObj);
			vTrackSegments = new ReadList<DisplayUtil.TrackSegment>();
			vTrackCuts = new ReadList<DisplayUtil.TrackSegment>();

			////

			if ( vSliderItem.Ticks > 1 ) {
				Vector3 quadScale = new Vector3(UiHoverMeshRect.SizeInset*2, 0.36f, 0.1f);
				float percPerTick = 1/(float)(vSliderItem.Ticks-1);

				vTickMeshBuilder = new MeshBuilder();
				MeshUtil.BuildQuadMesh(vTickMeshBuilder);
				vTickMeshBuilder.Commit();
				vTickMeshBuilder.CommitColors(Color.clear);

				for ( int i = 0 ; i < vSliderItem.Ticks ; ++i ) {
					GameObject tickObj = new GameObject("Tick"+i);
					tickObj.transform.SetParent(gameObject.transform, false);
					tickObj.transform.localPosition = Vector3.right*(vSlideX0+vSlideW*i*percPerTick);
					tickObj.transform.localRotation = TickQuatRot;
					tickObj.transform.localScale = quadScale;
					tickObj.AddComponent<MeshRenderer>();

					MeshFilter tickFilt = tickObj.AddComponent<MeshFilter>();
					tickFilt.sharedMesh = vTickMeshBuilder.Mesh;

					vTicks[i] = tickObj;
				}
			}

			////

			vGrabHold = new GameObject("GrabHold");
			vGrabHold.transform.SetParent(gameObject.transform, false);
			vGrabHold.transform.localRotation = Quaternion.Inverse(gameObject.transform.localRotation);

			var grabObj = new GameObject("Grab");
			grabObj.transform.SetParent(vGrabHold.transform, false);

			vGrab = grabObj.AddComponent<UiItemSliderGrabRenderer>();
			vGrab.IsVert = vIsVert;
			vGrab.Build(vPanelState, vLayoutState, vItemState, vSettings);

			if ( vIsVert ) {
				vGrab.SetCustomSize(vHeight, vGrabW, false);
			}
			else {
				vGrab.SetCustomSize(vGrabW, vHeight, false);
			}

			////

			vHoverHold = new GameObject("HoverHold");
			vHoverHold.transform.SetParent(gameObject.transform, false);

			var hoverObj = new GameObject("Hover");
			hoverObj.transform.SetParent(vHoverHold.transform, false);

			vHover = new UiHoverMeshRect(hoverObj, "Hover");
		}
예제 #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public virtual void Build(IHoverboardPanelState pPanelState,
                                  IHoverboardLayoutState pLayoutState, IBaseItemState pItemState,
                                  IItemVisualSettings pSettings)
        {
            vPanelState  = pPanelState;
            vLayoutState = pLayoutState;
            vItemState   = pItemState;
            vSettings    = (ItemVisualSettingsStandard)pSettings;
            vSliderItem  = (ISliderItem)vItemState.Item;
            vTicks       = new GameObject[vSliderItem.Ticks];

            vWidth     = UiItem.Size * vSliderItem.Width;
            vHeight    = UiItem.Size * vSliderItem.Height;
            vIsVert    = (vHeight > vWidth);
            vGrabW     = 1;
            vZeroValue = (0 - vSliderItem.RangeMin) / (vSliderItem.RangeMax - vSliderItem.RangeMin);

            gameObject.transform.SetParent(gameObject.transform, false);
            gameObject.transform.localPosition = new Vector3(vWidth / 2, 0, vHeight / 2f);
            gameObject.transform.localRotation = Quaternion.AngleAxis((vIsVert ? 90 : 0), Vector3.up);

            if (vIsVert)                 //swap dimensions here + rotate graphics later
            {
                float tempW = vWidth;
                vWidth  = vHeight;
                vHeight = tempW;
            }

            vSlideX0 = (vGrabW - vWidth) / 2;
            vSlideW  = vWidth - vGrabW;

            ////

            vHiddenRect = new UiHoverMeshRectBg(gameObject);
            vHiddenRect.UpdateSize(vWidth, vHeight);

            var trackObj = new GameObject("Track");

            trackObj.transform.SetParent(gameObject.transform, false);
            trackObj.transform.localPosition = new Vector3(-vWidth / 2, 0, 0);

            vTrack         = new UiItemSliderTrackRenderer(trackObj);
            vTrackSegments = new ReadList <DisplayUtil.TrackSegment>();
            vTrackCuts     = new ReadList <DisplayUtil.TrackSegment>();

            ////

            if (vSliderItem.Ticks > 1)
            {
                Vector3 quadScale   = new Vector3(UiHoverMeshRect.SizeInset * 2, 0.36f, 0.1f);
                float   percPerTick = 1 / (float)(vSliderItem.Ticks - 1);

                vTickMeshBuilder = new MeshBuilder();
                MeshUtil.BuildQuadMesh(vTickMeshBuilder);
                vTickMeshBuilder.Commit();
                vTickMeshBuilder.CommitColors(Color.clear);

                for (int i = 0; i < vSliderItem.Ticks; ++i)
                {
                    GameObject tickObj = new GameObject("Tick" + i);
                    tickObj.transform.SetParent(gameObject.transform, false);
                    tickObj.transform.localPosition = Vector3.right * (vSlideX0 + vSlideW * i * percPerTick);
                    tickObj.transform.localRotation = TickQuatRot;
                    tickObj.transform.localScale    = quadScale;
                    tickObj.AddComponent <MeshRenderer>();

                    MeshFilter tickFilt = tickObj.AddComponent <MeshFilter>();
                    tickFilt.sharedMesh = vTickMeshBuilder.Mesh;

                    vTicks[i] = tickObj;
                }
            }

            ////

            vGrabHold = new GameObject("GrabHold");
            vGrabHold.transform.SetParent(gameObject.transform, false);
            vGrabHold.transform.localRotation = Quaternion.Inverse(gameObject.transform.localRotation);

            var grabObj = new GameObject("Grab");

            grabObj.transform.SetParent(vGrabHold.transform, false);

            vGrab        = grabObj.AddComponent <UiItemSliderGrabRenderer>();
            vGrab.IsVert = vIsVert;
            vGrab.Build(vPanelState, vLayoutState, vItemState, vSettings);

            if (vIsVert)
            {
                vGrab.SetCustomSize(vHeight, vGrabW, false);
            }
            else
            {
                vGrab.SetCustomSize(vGrabW, vHeight, false);
            }

            ////

            vHoverHold = new GameObject("HoverHold");
            vHoverHold.transform.SetParent(gameObject.transform, false);

            var hoverObj = new GameObject("Hover");

            hoverObj.transform.SetParent(vHoverHold.transform, false);

            vHover = new UiHoverMeshRect(hoverObj, "Hover");
        }