-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisplayObject.cs
More file actions
112 lines (96 loc) · 2.54 KB
/
DisplayObject.cs
File metadata and controls
112 lines (96 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using System;
using UnityEngine;
namespace Emmy.self_ui
{
public class DisplayObject:EventDispatcher
{
private bool _needResize;
public bool NeedResize
{
get { return this._needResize; }
}
protected bool isModi;
public bool IsModi
{
get { return isModi; }
}
internal DisplayObjectContainer _parent;
public DisplayObjectContainer Parent
{
get { return this._parent; }
}
private float _x;
public float X
{
get { return this._x; }
set
{
this._x = value;
this._needResize = true;
}
}
private float _y;
public float Y
{
get { return this._y; }
set
{
this._y = value;
this._needResize = true;
}
}
private float _width;
public float Width
{
get { return this._width; }
set
{
this._width = value;
this._needResize = true;
}
}
private float _height;
public float Height
{
get { return this._height; }
set
{
this._height = value;
this._needResize = true;
}
}
protected Rect _rect;
protected DisplayObject():base()
{
this.isModi = false;
this._needResize = false;
this._rect = new Rect();
}
public void Draw()
{
if (!this.isModi)
{
// TODO 如果return了,就不绘制了,不知道该如何保持绘制的ui不变,因此必须一直绘制ui
// return;
}
this.ReCalculateSize();
this.DoDraw();
this.isModi = false;
}
protected virtual void DoDraw()
{
throw new Exception("must be override!");
}
private void ReCalculateSize()
{
if (this._needResize)
{
this._rect.x = this._parent._rect.x + this._x;
this._rect.y = this._parent._rect.y + this._y;
this._rect.width = this._parent._rect.width + this._width;
this._rect.height = this._parent._rect.height + this._height;
this._needResize = false;
}
}
}
}