using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace UIWidgets {
///
/// Used only to attach custom editor DragSupport.
///
public abstract class BaseDragSupport : MonoBehaviour {
///
/// The drag points.
///
protected static Dictionary DragPoints;
Transform canvasTransform;
///
/// Gets a canvas transform of current gameobject.
///
protected Transform CanvasTransform {
get {
if (canvasTransform==null)
{
canvasTransform = Utilites.FindTopmostCanvas(transform);
}
return canvasTransform;
}
}
///
/// Gets the drag point.
///
public RectTransform DragPoint {
get {
if (DragPoints==null)
{
DragPoints = new Dictionary();
}
if (!DragPoints.ContainsKey(CanvasTransform))
{
var go = new GameObject("DragPoint");
var dragPoint = go.AddComponent();
dragPoint.SetParent(CanvasTransform, false);
dragPoint.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 0f);
dragPoint.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0f);
DragPoints.Add(CanvasTransform, dragPoint);
}
return DragPoints[CanvasTransform];
}
}
}
}