#define CURVEDUI_PRESENT //If you're an asset creator and want to see if CurvedUI is imported, just use "#if CURVEDUI_PRESENT [your code] #endif"
using System;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Collections.Generic;
#if CURVEDUI_TMP || TMP_PRESENT
using TMPro;
#endif
///
/// This class stores settings for the entire canvas. It also stores useful methods for converting cooridinates to and from 2d canvas to curved canvas, or world space.
/// CurvedUIVertexEffect components (added to every canvas gameobject)ask this class for per-canvas settings when applying their curve effect.
///
namespace CurvedUI
{
[AddComponentMenu("CurvedUI/CurvedUISettings")]
[RequireComponent(typeof(Canvas))]
public class CurvedUISettings : MonoBehaviour
{
public const string Version = "3.2";
#region SETTINGS
//Global settings
[SerializeField]
CurvedUIShape shape;
[SerializeField]
float quality = 1f;
[SerializeField]
bool interactable = true;
[SerializeField]
bool blocksRaycasts = true;
[SerializeField]
bool forceUseBoxCollider = false;
//Cyllinder settings
[SerializeField]
int angle = 90;
[SerializeField]
bool preserveAspect = true;
//Sphere settings
[SerializeField]
int vertAngle = 90;
//ring settings
[SerializeField]
float ringFill = 0.5f;
[SerializeField]
int ringExternalDiamater = 1000;
[SerializeField]
bool ringFlipVertical = false;
//internal system settings
int baseCircleSegments = 16;
//stored variables
Vector2 savedRectSize;
float savedRadius;
Canvas myCanvas;
RectTransform m_rectTransform;
#endregion
#region LIFECYCLE
void Awake()
{
// If this canvas is on Default layer, switch it to UI layer..
// this is to make sure that when using raycasting to detect interactions,
// nothing will interfere with it.
if (gameObject.layer == 0) this.gameObject.layer = 5;
//save initial variables
savedRectSize = RectTransform.rect.size;
}
void Start()
{
if (Application.isPlaying)
{
// lets get rid of any raycasters and add our custom one
// It will be responsible for handling interactions.
BaseRaycaster[] raycasters = GetComponents();
foreach(BaseRaycaster caster in raycasters)
{
if (!(caster is CurvedUIRaycaster))
caster.enabled = false;
}
this.gameObject.AddComponentIfMissing();
//find if there are any child canvases that may break interactions
Canvas[] canvases = GetComponentsInChildren