Ejemplo n.º 1
0
        /*--------------------------------------------------------------------------------------------*/
        public void TreeUpdate()
        {
            if (Shape == null)
            {
                Debug.LogWarning("No '" + typeof(HoverShape).Name + "' reference provided.");
                return;
            }

            HoverCanvas    canvas    = GetComponent <HoverCanvas>();
            HoverShapeRect shapeRect = (Shape as HoverShapeRect);
            HoverShapeArc  shapeArc  = (Shape as HoverShapeArc);

            if (shapeRect)
            {
                UpdateWithRect(canvas, shapeRect);
            }
            else if (shapeArc != null)
            {
                UpdateWithArc(canvas, shapeArc);
            }
            else
            {
                throw new Exception("Shape not supported: " + Shape);
            }
        }
Ejemplo n.º 2
0
        /*--------------------------------------------------------------------------------------------*/
        private void BuildTitleItem(GameObject pItemGo)
        {
            HoverItemBuilder build = pItemGo.AddComponent <HoverItemBuilder>();

            build.ItemType             = HoverItem.HoverItemType.Text;
            build.ButtonRendererPrefab = ButtonRendererPrefab;
            build.OnEditorTriggerButtonSelected();
            DestroyImmediate(build, false);

            ////

            HoverFillButtonArcUpdater fillArcUp =
                pItemGo.GetComponentInChildren <HoverFillButtonArcUpdater>();

            fillArcUp.EdgePosition = HoverFillButtonArcUpdater.EdgePositionType.Outer;

            HoverItemDataText data = pItemGo.GetComponent <HoverItemDataText>();

            data.Id    = "HovercastTitleItem";
            data.Label = "Hovercast";

            HoverShapeArc shapeArc = pItemGo.AddComponent <HoverShapeArc>();

            shapeArc.OuterRadius = 0.075f;
            shapeArc.InnerRadius = 0.015f;
            shapeArc.ArcDegrees  = 90;
        }
Ejemplo n.º 3
0
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateWithArc(HoverCanvas pHoverCanvas, HoverShapeArc pShapeArc)
        {
            pHoverCanvas.Controllers.Set(SettingsControllerMap.TransformLocalPosition + ".x", this);
            pHoverCanvas.Controllers.Set(HoverCanvas.SizeXName, this);

            pHoverCanvas.SizeX = pShapeArc.OuterRadius - pShapeArc.InnerRadius;

            Vector3 canvasLocalPos = pHoverCanvas.transform.localPosition;

            canvasLocalPos.x = pShapeArc.InnerRadius + pHoverCanvas.SizeX / 2;
            pHoverCanvas.transform.localPosition = canvasLocalPos;
        }
Ejemplo n.º 4
0
        /*--------------------------------------------------------------------------------------------*/
        private void BuildBackItem(GameObject pItemGo)
        {
            HoverItemBuilder build = pItemGo.AddComponent <HoverItemBuilder>();

            build.ItemType             = HoverItem.HoverItemType.Selector;
            build.ButtonRendererPrefab = ButtonRendererPrefab;
            build.OnEditorTriggerButtonSelected();
            DestroyImmediate(build, false);

            ////

            HovercastInterface inter = gameObject.GetComponent <HovercastInterface>();

            HoverItemDataSelector data = pItemGo.GetComponent <HoverItemDataSelector>();

            data.Id     = "HovercastBackItem";
            data.Label  = "";
            data.Action = SelectorActionType.NavigateOut;

#if UNITY_EDITOR
            UnityEditor.Events.UnityEventTools.AddPersistentListener(
                data.OnSelectedEvent, inter.OnRowSwitched);
#else
            data.OnSelectedEvent.AddListener(inter.OnRowSwitched);
#endif

            HoverFillButtonArcUpdater fillArcUp =
                pItemGo.GetComponentInChildren <HoverFillButtonArcUpdater>();
            fillArcUp.EdgePosition = HoverFillButtonArcUpdater.EdgePositionType.Outer;

            HoverCanvas can = pItemGo.GetComponentInChildren <HoverCanvas>();
            can.Alignment = HoverCanvas.CanvasAlignmentType.Custom;
            can.IconOuter.transform.localPosition = new Vector3(-40, 0, 0);

            HoverShapeArc shapeArc = pItemGo.AddComponent <HoverShapeArc>();
            shapeArc.OuterRadius = 0.015f;
            shapeArc.InnerRadius = 0;
            shapeArc.ArcDegrees  = 360;

            HovercastRowSwitchingInfo rowSwitch = pItemGo.AddComponent <HovercastRowSwitchingInfo>();
            rowSwitch.NavigateBack       = true;
            rowSwitch.RowEntryTransition = HovercastRowSwitchingInfo.RowEntryType.FromInside;

            pItemGo.AddComponent <HoverIndicatorOverrider>();
        }
        /*--------------------------------------------------------------------------------------------*/
        private void BuildTitleItem(GameObject pItemGo)
        {
            HoverItemBuilder build = pItemGo.AddComponent <HoverItemBuilder>();

            build.ItemType             = HoverItem.HoverItemType.Text;
            build.ButtonRendererPrefab = ButtonRendererPrefab;
            build.PerformBuild();

            ////

            HoverItemDataText data = pItemGo.GetComponent <HoverItemDataText>();

            data.Id    = "HovercastTitleItem";
            data.Label = "Hovercast";

            HoverShapeArc shapeArc = pItemGo.AddComponent <HoverShapeArc>();

            shapeArc.OuterRadius = 0.075f;
            shapeArc.InnerRadius = 0.015f;
            shapeArc.ArcDegrees  = 90;
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void BuildOpenItem(GameObject pItemGo)
        {
            HoverItemBuilder build = pItemGo.AddComponent <HoverItemBuilder>();

            build.ItemType             = HoverItem.HoverItemType.Selector;
            build.ButtonRendererPrefab = ButtonRendererPrefab;
            build.PerformBuild();

            ////

            HovercastInterface inter = gameObject.GetComponent <HovercastInterface>();

            HoverItemDataSelector data = pItemGo.GetComponent <HoverItemDataSelector>();

            data.Id    = "HovercastOpenItem";
            data.Label = "";

#if UNITY_EDITOR
            UnityEditor.Events.UnityEventTools.AddPersistentListener(
                data.OnSelectedEvent, inter.OnOpenToggled);
#else
            data.OnSelectedEvent.AddListener(inter.OnRowSwitched);
#endif

            HoverCanvas can = pItemGo.GetComponentInChildren <HoverCanvas>();

            var iconPivotGo = new GameObject("IconPivot");
            iconPivotGo.transform.SetParent(can.transform, false);

            var iconOpenGo = new GameObject("IconOpen");
            iconOpenGo.transform.SetParent(iconPivotGo.transform, false);

            var iconCloseGo = new GameObject("IconClose");
            iconCloseGo.transform.SetParent(iconPivotGo.transform, false);

            RectTransform iconPivotRectTx = iconPivotGo.AddComponent <RectTransform>();
            iconPivotRectTx.localPosition = new Vector3(-47.5f, 0, 0);
            iconPivotRectTx.localScale    = new Vector3(2.2f, 2.2f, 1);
            iconPivotRectTx.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 100);
            iconPivotRectTx.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 100);

            RectTransform iconOpenRectTx = iconOpenGo.AddComponent <RectTransform>();
            iconOpenRectTx.localPosition = new Vector3(19, 0, 0);
            iconOpenRectTx.localRotation = Quaternion.Euler(0, 0, -45);
            iconOpenRectTx.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 40);
            iconOpenRectTx.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 40);

            RectTransform iconCloseRectTx = iconCloseGo.AddComponent <RectTransform>();
            iconCloseRectTx.localPosition = new Vector3(19, 0, 0);
            iconCloseRectTx.localRotation = Quaternion.Euler(0, 0, -45);
            iconCloseRectTx.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 40);
            iconCloseRectTx.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 40);

            RawImage openImage = iconOpenGo.AddComponent <RawImage>();
            openImage.material = Resources.Load <Material>("Materials/HovercastIconsMaterial");
            openImage.uvRect   = new Rect(0.002f, 0.002f, 0.496f, 0.996f);

            RawImage closeImage = iconCloseGo.AddComponent <RawImage>();
            closeImage.material = openImage.material;
            closeImage.uvRect   = new Rect(0.502f, 0.002f, 0.496f, 0.996f);

            ////

            HoverShapeArc shapeArc = pItemGo.AddComponent <HoverShapeArc>();
            shapeArc.OuterRadius = 0.02f;
            shapeArc.InnerRadius = 0;
            shapeArc.ArcDegrees  = 360;

            HovercastOpenIcons icons = pItemGo.AddComponent <HovercastOpenIcons>();
            icons.OpenIcon  = iconOpenGo;
            icons.CloseIcon = iconCloseGo;
        }