如题: 直接代码
|
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 |
using
UnityEngine;using
System.Collections;using
System.Collections.Generic;/// <summary>/// 把panel单独取出来 重置其size/// </summary>[ExecuteInEditMode][RequireComponent(typeof(UIDraggablePanel))]public
class
ClipPanelPlugin : MonoBehaviour { public
bool
needReposition; public
enum
ScrollDirection { horizontal, vertical } public
ScrollDirection direction; // Use this for initialization void
Start () { StartCoroutine(startReset()); } IEnumerator startReset() { yield
return
new
WaitForSeconds(2f); resetPanel(); } void
resetPanel() { //把panel 单独取出来 Transform parent = transform.parent; List<Transform> children = new
List<Transform>(); Transform child = null; for
(int
i = 0, l = transform.childCount; i < l; i++) { child = transform.GetChild(0); child.parent = null; children.Add(child); } transform.parent = null; Vector3 scale = transform.localScale; scale.y = scale.z = scale.x = direction == ScrollDirection.vertical ? scale.y : scale.x; transform.localScale = scale; foreach
(Transform c in
children) { c.parent=transform; } transform.parent = parent; #if UNITY_EDITOR #else enabled=false; #endif } void
LateUpdate() { if
(needReposition) { needReposition = false; resetPanel(); } }} |
NGUI DragablePanel与UiStretch的兼容
原文:http://www.cnblogs.com/wolfsky6/p/3515127.html