NGUI DragablePanel与UiStretch的兼容

如题: 直接代码

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的兼容

上一篇:移动端适配的一些理解


下一篇:(node app.js运行)服务器连接数据库报错Error: ER ACCESS DENIED ERROR: Access denied for user 'root'@'localhost' (using password: YES)