Beispiel #1
0
    private Object MatchUIBinderType(UIBindField field)
    {
        GameObject go = field.obj as GameObject;

        switch (field.bindType)
        {
        case UIBinderType.GameObject:
            return(go);

        case UIBinderType.RectTransform:
            return(go.GetComponent <RectTransform>());

        case UIBinderType.Button:
            return(go.GetComponent <Button>());

        case UIBinderType.Slider:
            return(go.GetComponent <Slider>());

        case UIBinderType.Text:
            return(go.GetComponent <Text>());

        case UIBinderType.Image:
            return(go.GetComponent <Image>());
        }
        return(null);
    }
Beispiel #2
0
    public void RuntimeBind(Window window)
    {
        RectTransform rtf = GetComponent <RectTransform>();

        FieldInfo[] fieldInfos = window.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
        for (int fIdx = 0; fIdx < binderList.Length; fIdx++)
        {
            UIBindField uiField    = binderList[fIdx];
            string      binderName = uiField.obj.name;
            if (uiField.obj == null)
            {
                Debug.LogWarningFormat("Warning: {0} UIBinder Not Find Field {1}!", this.name, binderName);
                continue;
            }
            for (int i = 0; i < fieldInfos.Length; i++)
            {
                FieldInfo fieldInfo           = fieldInfos[i];
                string    reflectionFiledName = fieldInfo.Name;
                if (binderName == reflectionFiledName)
                {
                    fieldInfo.SetValue(window, uiField.obj);
                    break;
                }
            }
        }
    }
Beispiel #3
0
    private Type GetComponentType(UIBindField field)
    {
        switch (field.bindType)
        {
        case UIBinderType.GameObject:
            return(typeof(GameObject));

        case UIBinderType.RectTransform:
            return(typeof(RectTransform));

        case UIBinderType.Button:
            return(typeof(Button));

        case UIBinderType.Slider:
            return(typeof(Slider));

        case UIBinderType.Text:
            return(typeof(Text));

        case UIBinderType.Image:
            return(typeof(Image));
        }
        return(null);
    }