您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
39 行
1.3 KiB
39 行
1.3 KiB
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.RMGUI;
|
|
|
|
namespace RMGUI.GraphView.Demo
|
|
{
|
|
public class Circle : GraphElement
|
|
{
|
|
public override void DoRepaint(IStylePainter painter)
|
|
{
|
|
Handles.DrawSolidDisc(new Vector3(position.x + position.width/2, position.y + position.height/2, 0.0f),
|
|
new Vector3(0.0f, 0.0f, -1.0f),
|
|
position.width / 2.0f);
|
|
|
|
if (GetData<CircleData>() != null && GetData<CircleData>().selected)
|
|
{
|
|
Color oldColor = Handles.color;
|
|
Handles.color = Color.yellow;
|
|
Handles.DrawWireDisc(new Vector3(position.x + position.width/2, position.y + position.height/2, 0.0f),
|
|
new Vector3(0.0f, 0.0f, -1.0f),
|
|
position.width/2.0f+2.0f);
|
|
Handles.color = oldColor;
|
|
}
|
|
}
|
|
|
|
public override bool ContainsPoint(Vector2 localPoint)
|
|
{
|
|
return Vector2.Distance(new Vector2(position.width/2, position.height/2), localPoint-position.position) <= position.width / 2.0f;
|
|
}
|
|
|
|
public override bool Overlaps(Rect rectangle)
|
|
{
|
|
rectangle.position -= position.position;
|
|
var radius = position.width / 2.0f;
|
|
var p = new Vector2(Mathf.Max(rectangle.x, Mathf.Min(radius, rectangle.xMax)), Mathf.Max(rectangle.y, Mathf.Min(radius, rectangle.yMax)));
|
|
return Vector2.Distance(new Vector2(radius, radius), p) <= radius;
|
|
}
|
|
}
|
|
}
|