Esempio n. 1
0
        static void LogError(STATECODE _state)
        {
            switch (_state)
            {
            case STATECODE.STATE_PATH_ERROR:
                Debug.LogError("excel is not exist");
                break;

            case STATECODE.STATE_FORMAT_ERROR:
                Debug.LogError("Data format is not standard");
                break;

            case STATECODE.STATE_NOCLASS_ERROR:
                Debug.LogError("this class is not exist");
                break;

            case STATECODE.STATE_NOGAMEOBJECT_ERROR:
                Debug.LogError("GameObject can not be found");
                break;

            case STATECODE.STATE_NOPROPERTY_ERROR:
                Debug.LogError("this class have not this property");
                break;

            case STATECODE.STATE_VALUETRANSFER_ERROR:
                Debug.LogError("Data can not be Transferred");
                break;
            }
        }
Esempio n. 2
0
        static void Load()
        {
            STATECODE statecode = 0;

            statecode = LoadExcel(ExcelName);
            if (statecode != STATECODE.STATE_SUCCEED)
            {
                LogError(statecode);
                return;
            }
            for (int i = 0; i < KeyName.Length; i++)
            {
                GameObject[] tempResult = null;
                statecode = FindGameObject(ref tempResult, KeyName[i], MatchMode[i]);
                if (statecode != STATECODE.STATE_SUCCEED)
                {
                    LogError(statecode);
                    return;
                }
                for (int j = 0; j < tempResult.Length; j++)
                {
                    MonoBehaviour[] monothis = tempResult [j].GetComponents <MonoBehaviour> ();
                    for (int k = 0; k < monothis.Length; k++)
                    {
                        if (monothis [k].GetType().ToString() == ClassName [i])
                        {
                            FieldInfo fInfo = monothis [k].GetType().GetField(PropertyName[i]);
                            if (fInfo == null)
                            {
                                LogError(STATECODE.STATE_NOPROPERTY_ERROR);
                                return;
                            }
                            object tempTargetResult = null;
                            statecode = DataTransfer(DataType[i], DataValue[i], ref tempTargetResult);
                            if (statecode != STATECODE.STATE_SUCCEED)
                            {
                                LogError(statecode);
                                return;
                            }
                            fInfo.SetValue(monothis[k], tempTargetResult);
                            break;
                        }
                        if (k == monothis.Length - 1)
                        {
                            LogError(STATECODE.STATE_NOCLASS_ERROR);
                            return;
                        }
                    }
                }
            }
        }