示例#1
0
    private void CheckIsOk(OkCallBack intAction, OkCallBack floatAction, OkCallBack vector2Action, OkCallBack vector3Action, OkCallBack colorAction, OkCallBack2 intAction2, OkCallBack2 floatAction2, OkCallBack2 vector2Action2, OkCallBack2 vector3Action2, OkCallBack2 colorAction2)
    {
        Component c = GetComponent(ComponentName);

        if (null == c)
        {
            MyLog.Red("获取不到这个组件名 —— " + ComponentName);
            return;
        }
        Type type = c.GetType();

        switch (isProperty)
        {
        case EIsProperty.Property:
            CheckProperty(type, c, intAction, floatAction, vector2Action, vector3Action, colorAction);
            break;

        case EIsProperty.Field:
            CheckField(type, c, intAction2, floatAction2, vector2Action2, vector3Action2, colorAction2);
            break;
        }
    }
示例#2
0
    private void CheckProperty(Type type, Component c, OkCallBack intAction, OkCallBack floatAction, OkCallBack vector2Action, OkCallBack vector3Action, OkCallBack colorAction)
    {
        PropertyInfo pInfo = type.GetProperty(PropertyName);

        if (null == pInfo)
        {
            MyLog.Red("1. 看下是否属性  2.看下有没有写错属性名");
        }
        else
        {
            Type lieType = pInfo.GetValue(c, null).GetType();
            switch (TO)
            {
            case EValueType.INT:
                if (lieType == typeof(Int32))
                {
                    if (null != intAction)
                    {
                        intAction(pInfo, c);
                    }
                }
                else
                {
                    MyLog.Red(string.Format("不是 {0} 类型,而是 {1}", typeof(Int32), lieType));
                }
                break;

            case EValueType.FLOAT:
                if (lieType == typeof(Single))
                {
                    if (null != floatAction)
                    {
                        floatAction(pInfo, c);
                    }
                }
                else
                {
                    MyLog.Red(string.Format("不是 {0} 类型,而是 {1}", typeof(Single), lieType));
                }
                break;

            case EValueType.VECTOR2:
                if (lieType == typeof(Vector2))
                {
                    if (null != vector2Action)
                    {
                        vector2Action(pInfo, c);
                    }
                }
                else
                {
                    MyLog.Red(string.Format("不是 {0} 类型,而是 {1}", typeof(Vector2), lieType));
                }
                break;

            case EValueType.VECTOR3:
                if (lieType == typeof(Vector3))
                {
                    if (null != vector3Action)
                    {
                        vector3Action(pInfo, c);
                    }
                }
                else
                {
                    MyLog.Red(string.Format("不是 {0} 类型,而是 {1}", typeof(Vector3), lieType));
                }
                break;

            case EValueType.COLOR:
                if (lieType == typeof(Color))
                {
                    if (null != colorAction)
                    {
                        colorAction(pInfo, c);
                    }
                }
                else
                {
                    MyLog.Red(string.Format("不是 {0} 类型,而是 {1}", typeof(Color), lieType));
                }
                break;

            default:
                MyLog.Red(string.Format("这个 {0} 类型没有定义", lieType));
                break;
            }
        }
    }