Ejemplo n.º 1
0
        /// <summary>
        /// Initialization of widget.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="viewDesignPrefab"></param>
        public void Init(RosJsonMessage context, GameObject viewDesignPrefab)
        {
            this.context          = context;
            id                    = context.id;
            childWidgetId         = context.childWidgetId;
            position              = WidgetUtility.StringToWidgetPosition(context.widgetPosition);
            relativeChildPosition = WidgetUtility.StringToRelativeChildPosition(context.relativeChildPosition);
            trainingInfo          = context.trainingInfo;

            this.viewDesignPrefab = viewDesignPrefab;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Show view by activating TextMeshPro, background images and setting the position and parent.
        /// </summary>
        /// <param name="relativeChildPosition"></param>
        public override void ShowView(RelativeChildPosition relativeChildPosition)
        {
            textMeshPro.enabled = true;

            foreach (RawImage image in images)
            {
                image.enabled = true;
            }

            Vector3 offsetVector = Vector3.zero;

            switch (relativeChildPosition)
            {
            case RelativeChildPosition.Bottom:
                offsetVector = Vector3.down * RELATIVE_OFFSET;
                break;

            case RelativeChildPosition.Top:
                offsetVector = Vector3.up * RELATIVE_OFFSET;
                break;

            case RelativeChildPosition.Left:
                offsetVector = Vector3.left * RELATIVE_OFFSET * 2;
                break;

            case RelativeChildPosition.Right:
                offsetVector = Vector3.right * RELATIVE_OFFSET * 2;
                break;

            case RelativeChildPosition.FixedCenter:
                transform.SetParent(GameObject.FindGameObjectWithTag("WidgetsCenter").transform, false);
                return;

            case RelativeChildPosition.Incorrect:
                return;
            }

            gameObject.AddComponent <CurvedUI.CurvedUIVertexEffect>();

            transform.SetParent(parentView.transform, false);

            transform.localPosition = offsetVector;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called at initialization.
        /// </summary>
        /// <param name="relativeChildPosition"></param>
        /// <param name="dwellTimerDuration"></param>
        /// <param name="onActivate">The name of the function that should be called when the widget gets activated.</param>
        /// <param name="onClose">The name of the function that should be called when the widget gets activated.</param>
        /// <param name="xPositionOffset">x Position offset in json file for better adjustment</param>
        /// <param name="yPositionOffset">y Position offset in json file for better adjustment</param>
        /// <param name="scale">scale in json file for better adjustment</param>
        public void Init(RelativeChildPosition relativeChildPosition, float dwellTimerDuration, string onActivate, string onClose, float xPositionOffset, float yPositionOffset, float scale)
        {
            SetRelativeChildPosition(relativeChildPosition);
            this.dwellTimerDuration = dwellTimerDuration;

            if (dwellTimerDuration > 0 && WidgetInteraction.Instance.allowDwellTime)
            {
                useDwellTimer = true;
            }

            dwellTimerImage = gameObject.GetComponentInChildren <Image>();

            if (WidgetInteraction.Instance.allowDwellTime)
            {
                keepChildUnfoldedTimer = new Timer();
            }
            dwellTimer = new Timer();

            // set x and y position of the widget, z position can be ignored
            transform.localPosition = new Vector3(xPositionOffset, yPositionOffset, 0);

            if (scale != 0)
            {
                // if scale is set in json file adjust scale for x,y,z
                transform.localScale = new Vector3(scale, scale, scale);
            }

            this.onActivate = onActivate;
            this.onClose    = onClose;

            Button btn = GetComponentInChildren <Button>();

            if (btn != null)
            {
                btn.onClick.AddListener(ToggleChildFold);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Set all view components visible.
 /// </summary>
 /// <param name="relativeChildPosition"></param>
 public abstract void ShowView(RelativeChildPosition relativeChildPosition);
Ejemplo n.º 5
0
 /// <summary>
 /// Set relative child position.
 /// </summary>
 /// <param name="relativeChildPosition"></param>
 public void SetRelativeChildPosition(RelativeChildPosition relativeChildPosition)
 {
     this.relativeChildPosition = relativeChildPosition;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Empty. Toastr view is never hidden
 /// </summary>
 /// <param name="relativeChildPosition"></param>
 public override void ShowView(RelativeChildPosition relativeChildPosition)
 {
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Makes view visible. Icon is never child widget until now, so this functionality is still missing here.
 /// </summary>
 /// <param name="relativeChildPosition"></param>
 public override void ShowView(RelativeChildPosition relativeChildPosition)
 {
     image.enabled = true;
 }