123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using SC.XR.Unity.Module_Tooltip;
- public class API_Module_Tooltip
- {
- /// <summary>
- /// Return whether the tooltip is activie.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <returns></returns>
- public static bool IsActivie(GameObject tooltip)
- {
- return tooltip.activeSelf;
- }
- /// <summary>
- /// Set active of the tooltip.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="state">True to set active and false to set inactive.</param>
- public static void SetActive(GameObject tooltip, bool state)
- {
- tooltip.SetActive(state);
- }
- /// <summary>
- /// Return the position of target.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="isWorldPosition">True to return worldPosition,false to return localPosition.</param>
- /// <returns></returns>
- public static Vector3 GetTargetPosition(GameObject tooltip, bool isWorldPosition)
- {
- return tooltip.GetComponent<Modules_TooltipLineRenderer>().API_GetTargetPosition(isWorldPosition);
- }
- /// <summary>
- /// Set new position of target.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="newPosition">New position of targer.</param>
- /// <param name="isWorldPosition">Whether new position is a world position or a local position.</param>
- public static void SetTargetPosition(GameObject tooltip, Vector3 newPosition, bool isWorldPosition)
- {
- tooltip.GetComponent<Modules_TooltipLineRenderer>().API_SetTargetPosition(newPosition, isWorldPosition);
- }
- /// <summary>
- /// Return he position of lable.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="isWorldPosition">Whether new position is a world position or a local position.</param>
- /// <returns></returns>
- public static Vector3 GetLablePosition(GameObject tooltip, bool isWorldPosition)
- {
- return tooltip.GetComponent<Modules_TooltipLineRenderer>().API_GetLablePosition(isWorldPosition);
- }
- /// <summary>
- /// Set new position of lable.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="newPosition">New position of lable.</param>
- /// <param name="isWorldPosition">Whether new position is a world position or a local position.</param>
- public static void SetLablePosition(GameObject tooltip, Vector3 newPosition, bool isWorldPosition)
- {
- tooltip.GetComponent<Modules_TooltipLineRenderer>().API_SetLablePosition(newPosition, isWorldPosition);
- }
- /// <summary>
- /// Return the type of TooltipStartPointLocation.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <returns></returns>
- public static Modules_TooltipLineRenderer.TooltipStartPointLocation GetStartPoint(GameObject tooltip)
- {
- return tooltip.GetComponent<Modules_TooltipLineRenderer>().API_GetStartPoint();
- }
- /// <summary>
- /// Set the type of TooltipStartPointLocation.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="tooltipStartPoint">Type of TooltipStartPointLocation.</param>
- public static void SetStartPoint(GameObject tooltip, Modules_TooltipLineRenderer.TooltipStartPointLocation tooltipStartPoint)
- {
- tooltip.GetComponent<Modules_TooltipLineRenderer>().API_SetStartPoint(tooltipStartPoint);
- }
- /// <summary>
- /// Return the position of startpoint.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="isWorldPosition">Whether new position is a world position or a local position.</param>
- /// <returns></returns>
- public static Vector3 GetStartPointPosition(GameObject tooltip, bool isWorldPosition)
- {
- return tooltip.GetComponent<Modules_TooltipLineRenderer>().API_GetStartPointPosition(isWorldPosition);
- }
- /// <summary>
- /// Set the width of line.(Range(0, 0.01))
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="width">Width of line.</param>
- public static void SetLineWidth(GameObject tooltip, float width)
- {
- tooltip.GetComponent<Modules_TooltipLineRenderer>().API_SetLineWidth(width);
- }
- /// <summary>
- /// Return the text of lable.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <returns></returns>
- public static string GetLableText(GameObject tooltip)
- {
- return tooltip.GetComponent<Modules_TooltipUI>().API_GetLableText();
- }
- /// <summary>
- /// Set text of lable.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="newText">Text to set.</param>
- public static void SetLableText(GameObject tooltip, string newText)
- {
- tooltip.GetComponent<Modules_TooltipUI>().API_SetLableText(newText);
- }
- /// <summary>
- /// Set color of text.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="color">Color to set.</param>
- public static void SetLableTextColor(GameObject tooltip, Color color)
- {
- tooltip.GetComponent<Modules_TooltipUI>().API_SetLableTextColor(color);
- }
- /// <summary>
- /// Set size of text.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="size">Size to set.</param>
- public static void SetLableTextSize(GameObject tooltip, float size)
- {
- tooltip.GetComponent<Modules_TooltipUI>().API_SetLableTextSize(size);
- }
- /// <summary>
- /// Set size of lable(background and text).
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="width">Width of lable.</param>
- /// <param name="height">Height of lable.</param>
- public static void SetLableSize(GameObject tooltip, float width, float height)
- {
- tooltip.GetComponent<Modules_TooltipUI>().API_SetLableSize(width, height);
- }
- /// <summary>
- /// Set scale of lable.(Range(0, 0.01))
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="scale">Scale size.</param>
- public static void SetLableScale(GameObject tooltip, float scale)
- {
- tooltip.GetComponent<Modules_TooltipUI>().API_SetLableScale(scale);
- }
- /// <summary>
- /// Set whether the startpoint is visible.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="state">Whether the startpoint is visible.</param>
- public static void SetStartPointVisible(GameObject tooltip, bool state)
- {
- tooltip.GetComponent<Modules_TooltipLineRenderer>().API_SetStartPointVisible(state);
- }
- /// <summary>
- /// Set whether the line is visible.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="state">Whether the line is visible.</param>
- public static void SetLineVisible(GameObject tooltip, bool state)
- {
- tooltip.GetComponent<Modules_TooltipLineRenderer>().API_SetLineVisible(state);
- }
- /// <summary>
- /// Return the type of TooltipRotationAxis whitch lable rotates.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <returns></returns>
- public static Modules_Tooltip.TooltipRotationAxis GetTooltipRotationAxis(GameObject tooltip)
- {
- return tooltip.GetComponent<Modules_Tooltip>().API_GetTooltipRotationAxis();
- }
- /// <summary>
- /// Set the type of TooltipRotationAxis whitch lable rotates.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="tooltipRotationAxis"></param>
- public static void SetTooltipRotationAxis(GameObject tooltip, Modules_Tooltip.TooltipRotationAxis tooltipRotationAxis)
- {
- tooltip.GetComponent<Modules_Tooltip>().API_SetTooltipRotationAxis(tooltipRotationAxis);
- }
- /// <summary>
- /// Change the target of TooltipRotationAxis whitch lable rotates.
- /// </summary>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="target">New target of TooltipRotationAxis whitch lable rotates.</param>
- public static void SetTooltipRotationAxisTarget(GameObject tooltip, Transform target)
- {
- tooltip.GetComponent<Modules_Tooltip>().API_SetTooltipRotationAxisTarget(target);
- }
- public static Modules_TooltipCtrl.TooltipShowTrigger GetTooltipShowTrigger(Modules_TooltipCtrl aimObject, GameObject tooltip)
- {
- return aimObject.API_GetTooltipShowTrigger(tooltip);
- }
- /// <summary>
- /// Set TooltipShowTrigger of the tooltip.(The tooltip should be created by Modules_TooltipCtrl.)
- /// </summary>
- /// <param name="aimObject">The parent gameobject of tooltip with Modules_TooltipCtrl.</param>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- /// <param name="showTrigger">When will the tooltip show.</param>
- public static void SetTooltipShowTrigger(Modules_TooltipCtrl aimObject, GameObject tooltip, Modules_TooltipCtrl.TooltipShowTrigger showTrigger)
- {
- aimObject.API_SetTooltipShowTrigger(tooltip, showTrigger);
- }
- /// <summary>
- /// Add a new tooltip as chlid of aimObject.
- /// </summary>
- /// <param name="aimObject">The parent gameobject of new tooltip.</param>
- /// <param name="showTrigger">When will the tooltip show.</param>
- /// <param name="text">Text of lable.</param>
- /// <returns></returns>
- public static GameObject AddNewTooltip(GameObject parentObject, Modules_TooltipCtrl.TooltipShowTrigger showTrigger, string text)
- {
- if (parentObject.GetComponent<Modules_TooltipCtrl>())
- {
- return parentObject.GetComponent<Modules_TooltipCtrl>().API_AddNewTooltip(showTrigger, text);
- }
- else
- {
- if (!parentObject.GetComponent<Collider>())
- {
- parentObject.AddComponent<BoxCollider>();
- }
- parentObject.AddComponent<Modules_TooltipCtrl>();
- return parentObject.GetComponent<Modules_TooltipCtrl>().API_AddNewTooltip(showTrigger, text);
- }
- }
- /// <summary>
- /// Delete the tooltip whitch as a child gameobject.(The tooltip should be created by Modules_TooltipCtrl.)
- /// </summary>
- /// <param name="aimObject">The parent gameobject of tooltip with Modules_TooltipCtrl.</param>
- /// <param name="tooltip">GameObject of Tooltip.</param>
- public static void DelTooltip(Modules_TooltipCtrl parentObject, GameObject tooltip)
- {
- parentObject.API_DelTooltip(tooltip);
- }
- }
|