#define Graph_And_Chart_PRO
using ChartAndGraph;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
///
/// posistions world space text on a special canvas used for billboarding.
///
[RequireComponent(typeof(ChartItem))]
[ExecuteInEditMode]
public class TextController : MonoBehaviour
{
public Camera Camera = null;
Canvas mCanvas;
RectTransform mRect;
List mText = new List();
public float PlaneDistance = 4;
Vector3[] mPlaneCorners = new Vector3[4];
bool mInvalidated = false;
private AnyChart mPrivateParent;
float mPrevScale = -1f;
bool OwnsCanvas = false;
//private bool mUnderCanvas = false;
internal List Text { get { return mText; } }
GameObject mAddCanvasUnder = null;
float mInnerScale = 1.0f;
public float GlobalRotation
{
get; set;
}
internal void SetInnerScale(float scale)
{
mInnerScale = scale;
}
internal AnyChart mParent
{
get { return mPrivateParent; }
set
{
mPrivateParent = value;
if (mPrivateParent != null)
{
Camera = ((IInternalUse)mPrivateParent).InternalTextCamera;
PlaneDistance = ((IInternalUse)mPrivateParent).InternalTextIdleDistance;
if (OwnsCanvas)
SafeCanvas.planeDistance = PlaneDistance;
}
}
}
void Start()
{
EnsureCanvas();
Canvas.willRenderCanvases += Canvas_willRenderCanvases;
}
private void OnDestroy()
{
Canvas.willRenderCanvases -= Canvas_willRenderCanvases;
}
private void Canvas_willRenderCanvases()
{
if (this == null)
{
Canvas.willRenderCanvases -= Canvas_willRenderCanvases;
return;
}
ApplyTextPosition();
}
void EnsureCanvas()
{
if (mCanvas == null)
{
mCanvas = GetComponentInParent