Ejemplo n.º 1
0
 public void Inject(LuaTable self)
 {
     for (int i = 0; i < injections.Length; i++)
     {
         Injection injection = injections[i];
         string[]  path      = injection.key.Split('.');
         LuaTable  toBeSet   = self;
         for (int j = 0; j < path.Length - 1; j++)
         {
             toBeSet = toBeSet.Get <LuaTable>(path[j]);
         }
         string key = path[path.Length - 1];
         if (key.Contains("#"))
         {
             string[] listKey = key.Split('#');
             int      index   = System.Convert.ToInt32(listKey[1]);
             toBeSet = toBeSet.Get <LuaTable>(listKey[0]);
             SetByType(toBeSet, index, injection);
         }
         else
         {
             SetByType(toBeSet, key, injection);
         }
     }
 }
Ejemplo n.º 2
0
 void Awake()
 {
     for (int i = 0; i < injections.Length; i++)
     {
         Injection pair = injections[i];
         dict.Add(pair.key, pair.value);
     }
 }
Ejemplo n.º 3
0
 private void SetByType <T>(LuaTable table, T key, Injection injection)
 {
     if (injection.typeName == typeof(int).FullName)
     {
         table.Set(key, injection.nonObjectValue.intValue);
     }
     else if (injection.typeName == typeof(float).FullName)
     {
         table.Set(key, injection.nonObjectValue.floatValue);
     }
     else if (injection.typeName == typeof(bool).FullName)
     {
         table.Set(key, injection.nonObjectValue.boolValue);
     }
     else if (injection.typeName == typeof(string).FullName)
     {
         table.Set(key, injection.nonObjectValue.stringValue);
     }
     else if (injection.typeName == typeof(Vector2).FullName)
     {
         table.Set(key, injection.nonObjectValue.v2Value);
     }
     else if (injection.typeName == typeof(Vector3).FullName)
     {
         table.Set(key, injection.nonObjectValue.v3Value);
     }
     else if (injection.typeName == typeof(Vector4).FullName)
     {
         table.Set(key, injection.nonObjectValue.v4Value);
     }
     else if (injection.typeName == typeof(AnimationCurve).FullName)
     {
         table.Set(key, injection.nonObjectValue.animationCurveValue);
     }
     else
     {
         table.Set(key, injection.value);
     }
 }
Ejemplo n.º 4
0
 public void Inject(LuaTable self)
 {
     for (int i = 0; i < injections.Length; i++)
     {
         Injection pair = injections[i];
         if (pair.key.Contains("."))
         {
             self.SetInPath(pair.key, pair.value);   // SetInPath必须保证Path不为nil
         }
         else if (pair.key.Contains("#"))
         {
             string[] info      = pair.key.Split('#');
             string   tableName = info[0];
             int      index     = System.Convert.ToInt32(info[1]);
             LuaTable table     = self.Get <LuaTable>(tableName); // 与SetInPath规则保持一致,此处table不能为nil
             table.Set(index, pair.value);
         }
         else
         {
             self.Set(pair.key, pair.value);
         }
     }
 }