summaryrefslogtreecommitdiff
path: root/Assets/Test/06_Layout/UI06Test.cs
blob: da4d269b0a293340ff3030090a34cbf35e0618ef (plain)
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
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;


interface ITest
{
    void Test();
}
interface ITest2
{
    void Test();
}

class Dual : ITest //, ITest2
{

    void ITest.Test()
    {
        Debug.Log("test");
    }

    //void ITest.Test()
    //{
    //    Debug.Log("ITest.Test");
    //}

    //void ITest2.Test()
    //{
    //    Debug.Log("ITest2.Test");
    //}
}

public interface IS
{
    void Foo();
}

public interface IS2
{
    void Foo();
}
struct StructA : IS
{
    public static int value2 = 29;
    public int value;
    public RectTransform rectTransform;
    public StructA(RectTransform rect, int v)
    {
  //      Debug.Log("StructA()");
        this.rectTransform = rect;
        this.value = v;
    }

    public void Foo()
    {
        throw new NotImplementedException();
    }
}



public class UI06Test : MonoBehaviour {

    public delegate void ClickHandler();
    public event ClickHandler OnClick;
    public delegate void BroadcastCallback(params object[] objs);

    // Use this for initialization
    void Start () {
        //    OnClick += () => { Debug.Log("1"); };
        //    OnClick += () => { Debug.Log("2"); };
        //    OnClick += Foo;
        //    OnClick += Foo;
        //    OnClick += Foo;
        //    OnClick += () => { Debug.Log("3"); };
        //    OnClick += () => { Debug.Log("4"); };
        //    OnClick += () => { Debug.Log("5"); };
        //    OnClick -= Foo;
        //    OnClick -= Foo;
        //    OnClick -= Foo;
        //    OnClick = OnClick - Foo;
        ////    Delegate.Remove(OnClick, Foo);
        //    OnClick();
        //    ClickHandler f2 = new ClickHandler(Foo);
        //    ClickHandler f3 = Foo;
        //    Dictionary<int, float> a;
        RectTransform rect = GetComponent<RectTransform>();
        StructA a = new StructA(rect, 1);
        Debug.Log(a.GetHashCode());
        StructA a2 = new StructA(null, 1);
        Debug.Log(a2.GetHashCode());
        StructA b = new StructA(rect, 2);
        Debug.Log(b.GetHashCode());
        Dictionary<StructA, int> d = new Dictionary<StructA, int>();
        d.Add(a, 10);
        if (d.ContainsKey(a2))
        {
            Debug.Log("包含");
        }
        else
        {
            Debug.Log("不包含");
        }
        System.Object obj = new object();
        Debug.Log(obj.GetHashCode());
        System.Object obj2 = new object();
        Debug.Log(obj2.GetHashCode());
        //StructA? bb;
        Nullable<StructA> bb;
        bb = null;
        ITest dual = new Dual();
        dual.Test();
    }

    void Foo()
    {
        Debug.Log("Foo()");
    }

}