Esempio n. 1
0
 static int ValueChanged(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         BehaviorDesigner.Runtime.SharedVariable obj = (BehaviorDesigner.Runtime.SharedVariable)ToLua.CheckObject <BehaviorDesigner.Runtime.SharedVariable>(L, 1);
         obj.ValueChanged();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 2
0
 static int GetValue(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         BehaviorDesigner.Runtime.SharedVariable obj = (BehaviorDesigner.Runtime.SharedVariable)ToLua.CheckObject <BehaviorDesigner.Runtime.SharedVariable>(L, 1);
         object o = obj.GetValue();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 3
0
 static int InitializePropertyMapping(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         BehaviorDesigner.Runtime.SharedVariable obj  = (BehaviorDesigner.Runtime.SharedVariable)ToLua.CheckObject <BehaviorDesigner.Runtime.SharedVariable>(L, 1);
         BehaviorDesigner.Runtime.BehaviorSource arg0 = (BehaviorDesigner.Runtime.BehaviorSource)ToLua.CheckObject <BehaviorDesigner.Runtime.BehaviorSource>(L, 2);
         obj.InitializePropertyMapping(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 4
0
 static int SetValue(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         BehaviorDesigner.Runtime.SharedVariable obj = (BehaviorDesigner.Runtime.SharedVariable)ToLua.CheckObject <BehaviorDesigner.Runtime.SharedVariable>(L, 1);
         object arg0 = ToLua.ToVarObject(L, 2);
         obj.SetValue(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 5
0
    static int get_IsShared(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BehaviorDesigner.Runtime.SharedVariable obj = (BehaviorDesigner.Runtime.SharedVariable)o;
            bool ret = obj.IsShared;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index IsShared on a nil value"));
        }
    }
Esempio n. 6
0
    static int get_PropertyMapping(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BehaviorDesigner.Runtime.SharedVariable obj = (BehaviorDesigner.Runtime.SharedVariable)o;
            string ret = obj.PropertyMapping;
            LuaDLL.lua_pushstring(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index PropertyMapping on a nil value"));
        }
    }
Esempio n. 7
0
    static int set_NetworkSync(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BehaviorDesigner.Runtime.SharedVariable obj = (BehaviorDesigner.Runtime.SharedVariable)o;
            bool arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.NetworkSync = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index NetworkSync on a nil value"));
        }
    }
Esempio n. 8
0
    static int set_PropertyMappingOwner(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BehaviorDesigner.Runtime.SharedVariable obj = (BehaviorDesigner.Runtime.SharedVariable)o;
            UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 2, typeof(UnityEngine.GameObject));
            obj.PropertyMappingOwner = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index PropertyMappingOwner on a nil value"));
        }
    }
Esempio n. 9
0
    static int set_PropertyMapping(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BehaviorDesigner.Runtime.SharedVariable obj = (BehaviorDesigner.Runtime.SharedVariable)o;
            string arg0 = ToLua.CheckString(L, 2);
            obj.PropertyMapping = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index PropertyMapping on a nil value"));
        }
    }
Esempio n. 10
0
    static int get_PropertyMappingOwner(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BehaviorDesigner.Runtime.SharedVariable obj = (BehaviorDesigner.Runtime.SharedVariable)o;
            UnityEngine.GameObject ret = obj.PropertyMappingOwner;
            ToLua.PushSealed(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index PropertyMappingOwner on a nil value"));
        }
    }
Esempio n. 11
0
 public void UpdateVariableName(SharedVariable sharedVariable, string name)
 {
     CheckForSerialization(false, null);
     sharedVariable.Name = name;
     this.UpdateVariablesIndex();
 }
Esempio n. 12
0
        private static object ValueToObject(Task task, Type type, object obj, IVariableSource variableSource, List <UnityEngine.Object> unityObjects)
        {
            if (type.Equals(typeof(SharedVariable)) || type.IsSubclassOf(typeof(SharedVariable)))
            {
                SharedVariable sharedVariable = DeserializeJSON.DeserializeSharedVariable(obj as Dictionary <string, object>, variableSource, false, unityObjects);
                if (sharedVariable == null)
                {
                    sharedVariable = (TaskUtility.CreateInstance(type) as SharedVariable);
                }
                return(sharedVariable);
            }
            if (type.Equals(typeof(UnityEngine.Object)) || type.IsSubclassOf(typeof(UnityEngine.Object)))
            {
                return(DeserializeJSON.IndexToUnityObject(Convert.ToInt32(obj), unityObjects));
            }
            if (!type.IsPrimitive)
            {
                if (!type.Equals(typeof(string)))
                {
                    goto IL_C5;
                }
            }
            try
            {
                object result = Convert.ChangeType(obj, type);
                return(result);
            }
            catch (Exception)
            {
                object result = null;
                return(result);
            }
IL_C5:
            if (type.IsSubclassOf(typeof(Enum)))
            {
                try
                {
                    object result = Enum.Parse(type, (string)obj);
                    return(result);
                }
                catch (Exception)
                {
                    object result = null;
                    return(result);
                }
            }
            if (type.Equals(typeof(Vector2)))
            {
                return(DeserializeJSON.StringToVector2((string)obj));
            }
            if (type.Equals(typeof(Vector3)))
            {
                return(DeserializeJSON.StringToVector3((string)obj));
            }
            if (type.Equals(typeof(Vector4)))
            {
                return(DeserializeJSON.StringToVector4((string)obj));
            }
            if (type.Equals(typeof(Quaternion)))
            {
                return(DeserializeJSON.StringToQuaternion((string)obj));
            }
            if (type.Equals(typeof(Matrix4x4)))
            {
                return(DeserializeJSON.StringToMatrix4x4((string)obj));
            }
            if (type.Equals(typeof(Color)))
            {
                return(DeserializeJSON.StringToColor((string)obj));
            }
            if (type.Equals(typeof(Rect)))
            {
                return(DeserializeJSON.StringToRect((string)obj));
            }
            if (type.Equals(typeof(LayerMask)))
            {
                return(DeserializeJSON.ValueToLayerMask(Convert.ToInt32(obj)));
            }
            if (type.Equals(typeof(AnimationCurve)))
            {
                return(DeserializeJSON.ValueToAnimationCurve((Dictionary <string, object>)obj));
            }
            object obj2 = TaskUtility.CreateInstance(type);

            DeserializeJSON.DeserializeObject(task, obj2, obj as Dictionary <string, object>, variableSource, unityObjects);
            return(obj2);
        }
Esempio n. 13
0
 private static void DeserializeObject(Task task, object obj, Dictionary <string, object> dict, IVariableSource variableSource, List <UnityEngine.Object> unityObjects)
 {
     if (dict == null)
     {
         return;
     }
     FieldInfo[] allFields = TaskUtility.GetAllFields(obj.GetType());
     for (int i = 0; i < allFields.Length; i++)
     {
         object obj2;
         if (dict.TryGetValue(allFields[i].FieldType + "," + allFields[i].Name, out obj2) || dict.TryGetValue(allFields[i].Name, out obj2))
         {
             if (typeof(IList).IsAssignableFrom(allFields[i].FieldType))
             {
                 IList list = obj2 as IList;
                 if (list != null)
                 {
                     Type type;
                     if (allFields[i].FieldType.IsArray)
                     {
                         type = allFields[i].FieldType.GetElementType();
                     }
                     else
                     {
                         Type type2 = allFields[i].FieldType;
                         while (!type2.IsGenericType)
                         {
                             type2 = type2.BaseType;
                         }
                         type = type2.GetGenericArguments()[0];
                     }
                     bool flag = type.Equals(typeof(Task)) || type.IsSubclassOf(typeof(Task));
                     if (flag)
                     {
                         if (DeserializeJSON.taskIDs != null)
                         {
                             List <int> list2 = new List <int>();
                             for (int j = 0; j < list.Count; j++)
                             {
                                 list2.Add(Convert.ToInt32(list[j]));
                             }
                             DeserializeJSON.taskIDs.Add(new DeserializeJSON.TaskField(task, allFields[i]), list2);
                         }
                     }
                     else
                     {
                         if (allFields[i].FieldType.IsArray)
                         {
                             Array array = Array.CreateInstance(type, list.Count);
                             for (int k = 0; k < list.Count; k++)
                             {
                                 array.SetValue(DeserializeJSON.ValueToObject(task, type, list[k], variableSource, unityObjects), k);
                             }
                             allFields[i].SetValue(obj, array);
                         }
                         else
                         {
                             IList list3;
                             if (allFields[i].FieldType.IsGenericType)
                             {
                                 list3 = (TaskUtility.CreateInstance(typeof(List <>).MakeGenericType(new Type[]
                                 {
                                     type
                                 })) as IList);
                             }
                             else
                             {
                                 list3 = (TaskUtility.CreateInstance(allFields[i].FieldType) as IList);
                             }
                             for (int l = 0; l < list.Count; l++)
                             {
                                 list3.Add(DeserializeJSON.ValueToObject(task, type, list[l], variableSource, unityObjects));
                             }
                             allFields[i].SetValue(obj, list3);
                         }
                     }
                 }
             }
             else
             {
                 Type fieldType = allFields[i].FieldType;
                 if (fieldType.Equals(typeof(Task)) || fieldType.IsSubclassOf(typeof(Task)))
                 {
                     if (TaskUtility.HasAttribute(allFields[i], typeof(InspectTaskAttribute)))
                     {
                         Dictionary <string, object> dictionary = obj2 as Dictionary <string, object>;
                         Type typeWithinAssembly = TaskUtility.GetTypeWithinAssembly(dictionary["ObjectType"] as string);
                         if (typeWithinAssembly != null)
                         {
                             Task task2 = TaskUtility.CreateInstance(typeWithinAssembly) as Task;
                             DeserializeJSON.DeserializeObject(task2, task2, dictionary, variableSource, unityObjects);
                             allFields[i].SetValue(task, task2);
                         }
                     }
                     else
                     {
                         if (DeserializeJSON.taskIDs != null)
                         {
                             List <int> list4 = new List <int>();
                             list4.Add(Convert.ToInt32(obj2));
                             DeserializeJSON.taskIDs.Add(new DeserializeJSON.TaskField(task, allFields[i]), list4);
                         }
                     }
                 }
                 else
                 {
                     allFields[i].SetValue(obj, DeserializeJSON.ValueToObject(task, fieldType, obj2, variableSource, unityObjects));
                 }
             }
         }
         else
         {
             if (typeof(SharedVariable).IsAssignableFrom(allFields[i].FieldType))
             {
                 Type type3 = TaskUtility.SharedVariableToConcreteType(allFields[i].FieldType);
                 if (type3 == null)
                 {
                     return;
                 }
                 if (dict.TryGetValue(type3 + "," + allFields[i].Name, out obj2))
                 {
                     SharedVariable sharedVariable = TaskUtility.CreateInstance(allFields[i].FieldType) as SharedVariable;
                     sharedVariable.SetValue(DeserializeJSON.ValueToObject(task, type3, obj2, variableSource, unityObjects));
                     allFields[i].SetValue(obj, sharedVariable);
                 }
                 else
                 {
                     SharedVariable value = TaskUtility.CreateInstance(allFields[i].FieldType) as SharedVariable;
                     allFields[i].SetValue(obj, value);
                 }
             }
         }
     }
 }
Esempio n. 14
0
        private static SharedVariable DeserializeSharedVariable(Dictionary <string, object> dict, IVariableSource variableSource, bool fromSource, List <UnityEngine.Object> unityObjects)
        {
            if (dict == null)
            {
                return(null);
            }
            SharedVariable sharedVariable = null;
            object         obj;

            if (!fromSource && variableSource != null && dict.TryGetValue("Name", out obj))
            {
                object value;
                dict.TryGetValue("IsGlobal", out value);
                if (!dict.TryGetValue("IsGlobal", out value) || !Convert.ToBoolean(value))
                {
                    sharedVariable = variableSource.GetVariable(obj as string);
                }
                else
                {
                    if (DeserializeJSON.globalVariables == null)
                    {
                        DeserializeJSON.globalVariables = GlobalVariables.Instance;
                    }
                    if (DeserializeJSON.globalVariables != null)
                    {
                        sharedVariable = DeserializeJSON.globalVariables.GetVariable(obj as string);
                    }
                }
            }
            Type typeWithinAssembly = TaskUtility.GetTypeWithinAssembly(dict["Type"] as string);

            if (typeWithinAssembly == null)
            {
                return(null);
            }
            bool flag = true;

            if (sharedVariable == null || !(flag = sharedVariable.GetType().Equals(typeWithinAssembly)))
            {
                sharedVariable      = (TaskUtility.CreateInstance(typeWithinAssembly) as SharedVariable);
                sharedVariable.Name = (dict["Name"] as string);
                object obj2;
                if (dict.TryGetValue("IsShared", out obj2))
                {
                    sharedVariable.IsShared = Convert.ToBoolean(obj2);
                }
                if (dict.TryGetValue("IsGlobal", out obj2))
                {
                    sharedVariable.IsGlobal = Convert.ToBoolean(obj2);
                }
                if (dict.TryGetValue("NetworkSync", out obj2))
                {
                    sharedVariable.NetworkSync = Convert.ToBoolean(obj2);
                }
                if (!sharedVariable.IsGlobal && dict.TryGetValue("PropertyMapping", out obj2))
                {
                    sharedVariable.PropertyMapping = (obj2 as string);
                    if (dict.TryGetValue("PropertyMappingOwner", out obj2))
                    {
                        sharedVariable.PropertyMappingOwner = (DeserializeJSON.IndexToUnityObject(Convert.ToInt32(obj2), unityObjects) as GameObject);
                    }
                    sharedVariable.InitializePropertyMapping(variableSource as BehaviorSource);
                }
                if (!flag)
                {
                    sharedVariable.IsShared = true;
                }
                DeserializeJSON.DeserializeObject(null, sharedVariable, dict, variableSource, unityObjects);
            }
            return(sharedVariable);
        }
Esempio n. 15
0
        private static void DoVariablesToICodeSync(IVariableSource variableSource, FsmVariable[] iCodeVariables)
        {
            if (variableSource == null)
            {
                return;
            }

            SharedVariable behaviorDesignerVariable = null;
            FsmVariable    iCodeVariable            = null;

            for (int i = 0; i < iCodeVariables.Length; ++i)
            {
                iCodeVariable = iCodeVariables[i];
                if ((behaviorDesignerVariable = variableSource.GetVariable(iCodeVariable.Name)) != null)
                {
                    // FsmInt
                    if (iCodeVariable is FsmInt)
                    {
                        if (behaviorDesignerVariable is SharedInt)
                        {
                            (iCodeVariable as FsmInt).Value = (int)behaviorDesignerVariable.GetValue();
                        }
                        continue;
                    }

                    // FsmFloat
                    if (iCodeVariable is FsmFloat)
                    {
                        if (behaviorDesignerVariable is SharedFloat)
                        {
                            (iCodeVariable as FsmFloat).Value = (float)behaviorDesignerVariable.GetValue();
                        }
                        continue;
                    }

                    // FsmBool
                    if (iCodeVariable is FsmBool)
                    {
                        if (behaviorDesignerVariable is SharedBool)
                        {
                            (iCodeVariable as FsmBool).Value = (bool)behaviorDesignerVariable.GetValue();
                        }
                        continue;
                    }

                    // FsmString
                    if (iCodeVariable is FsmString)
                    {
                        if (behaviorDesignerVariable is SharedString)
                        {
                            (iCodeVariable as FsmString).Value = (string)behaviorDesignerVariable.GetValue();
                        }
                        continue;
                    }

                    // FsmColor
                    if (iCodeVariable is FsmColor)
                    {
                        if (behaviorDesignerVariable is SharedColor)
                        {
                            (iCodeVariable as FsmColor).Value = (Color)behaviorDesignerVariable.GetValue();
                        }
                        continue;
                    }

                    // FsmVector2
                    if (iCodeVariable is FsmVector2)
                    {
                        if (behaviorDesignerVariable is SharedVector2)
                        {
                            (iCodeVariable as FsmVector2).Value = (Vector2)behaviorDesignerVariable.GetValue();
                        }
                        continue;
                    }

                    // FsmVector3
                    if (iCodeVariable is FsmVector3)
                    {
                        if (behaviorDesignerVariable is SharedVector3)
                        {
                            (iCodeVariable as FsmVector3).Value = (Vector3)behaviorDesignerVariable.GetValue();
                        }
                        continue;
                    }

                    // FsmObject
                    if (iCodeVariable is FsmObject)
                    {
                        if (behaviorDesignerVariable is SharedGameObject)
                        {
                            (iCodeVariable as FsmObject).Value = (GameObject)behaviorDesignerVariable.GetValue();
                        }
                        else if (behaviorDesignerVariable is SharedObject)
                        {
                            (iCodeVariable as FsmObject).Value = (Object)behaviorDesignerVariable.GetValue();
                        }
                        continue;
                    }
                }
            }
        }
Esempio n. 16
0
 /// <summary>
 /// 设置指定名字的共享变量
 /// </summary>
 /// <param name="name"></param>
 /// <param name="item"></param>
 public void SetVariable(string name, SharedVariable item)
 {
     this.CheckForSerialization();
     this.mBehaviorSource.SetVariable(name, item);
 }
Esempio n. 17
0
 public GenericVariable()
 {
     this.value = (Activator.CreateInstance(TaskUtility.GetTypeWithinAssembly("BehaviorDesigner.Runtime.SharedString")) as SharedVariable);
 }
 private static void DeserializeObject(Task task, object obj, Dictionary <string, object> dict, IVariableSource variableSource, List <UnityEngine.Object> unityObjects)
 {
     if (dict == null)
     {
         return;
     }
     FieldInfo[] allFields = TaskUtility.GetAllFields(obj.GetType());
     for (int i = 0; i < allFields.Length; i++)
     {
         string key = (!JSONDeserialization.updatedSerialization) ? (allFields[i].FieldType.Name.GetHashCode() + allFields[i].Name.GetHashCode()).ToString() : (allFields[i].FieldType.Name + allFields[i].Name);
         object obj2;
         if (dict.TryGetValue(key, out obj2))
         {
             if (typeof(IList).IsAssignableFrom(allFields[i].FieldType))
             {
                 IList list = obj2 as IList;
                 if (list != null)
                 {
                     Type type;
                     if (allFields[i].FieldType.IsArray)
                     {
                         type = allFields[i].FieldType.GetElementType();
                     }
                     else
                     {
                         Type type2 = allFields[i].FieldType;
                         while (!type2.IsGenericType)
                         {
                             type2 = type2.BaseType;
                         }
                         type = type2.GetGenericArguments()[0];
                     }
                     bool flag = type.Equals(typeof(Task)) || type.IsSubclassOf(typeof(Task));
                     if (flag)
                     {
                         if (JSONDeserialization.taskIDs != null)
                         {
                             List <int> list2 = new List <int>();
                             for (int j = 0; j < list.Count; j++)
                             {
                                 list2.Add(Convert.ToInt32(list[j], CultureInfo.InvariantCulture));
                             }
                             JSONDeserialization.taskIDs.Add(new JSONDeserialization.TaskField(task, allFields[i]), list2);
                         }
                     }
                     else if (allFields[i].FieldType.IsArray)
                     {
                         Array array = Array.CreateInstance(type, list.Count);
                         for (int k = 0; k < list.Count; k++)
                         {
                             if (list[k] == null)
                             {
                                 array.SetValue(null, k);
                             }
                             else
                             {
                                 array.SetValue(JSONDeserialization.ValueToObject(task, type, list[k], variableSource, unityObjects), k);
                             }
                         }
                         allFields[i].SetValue(obj, array);
                     }
                     else
                     {
                         IList list3;
                         if (allFields[i].FieldType.IsGenericType)
                         {
                             list3 = (TaskUtility.CreateInstance(typeof(List <>).MakeGenericType(new Type[]
                             {
                                 type
                             })) as IList);
                         }
                         else
                         {
                             list3 = (TaskUtility.CreateInstance(allFields[i].FieldType) as IList);
                         }
                         for (int l = 0; l < list.Count; l++)
                         {
                             if (list[l] == null)
                             {
                                 list3.Add(null);
                             }
                             else
                             {
                                 list3.Add(JSONDeserialization.ValueToObject(task, type, list[l], variableSource, unityObjects));
                             }
                         }
                         allFields[i].SetValue(obj, list3);
                     }
                 }
             }
             else
             {
                 Type fieldType = allFields[i].FieldType;
                 if (fieldType.Equals(typeof(Task)) || fieldType.IsSubclassOf(typeof(Task)))
                 {
                     if (TaskUtility.HasAttribute(allFields[i], typeof(InspectTaskAttribute)))
                     {
                         Dictionary <string, object> dictionary = obj2 as Dictionary <string, object>;
                         Type typeWithinAssembly = TaskUtility.GetTypeWithinAssembly(dictionary["Type"] as string);
                         if (typeWithinAssembly != null)
                         {
                             Task task2 = TaskUtility.CreateInstance(typeWithinAssembly) as Task;
                             JSONDeserialization.DeserializeObject(task2, task2, dictionary, variableSource, unityObjects);
                             allFields[i].SetValue(task, task2);
                         }
                     }
                     else if (JSONDeserialization.taskIDs != null)
                     {
                         List <int> list4 = new List <int>();
                         list4.Add(Convert.ToInt32(obj2, CultureInfo.InvariantCulture));
                         JSONDeserialization.taskIDs.Add(new JSONDeserialization.TaskField(task, allFields[i]), list4);
                     }
                 }
                 else
                 {
                     allFields[i].SetValue(obj, JSONDeserialization.ValueToObject(task, fieldType, obj2, variableSource, unityObjects));
                 }
             }
         }
         else if (typeof(SharedVariable).IsAssignableFrom(allFields[i].FieldType) && !allFields[i].FieldType.IsAbstract)
         {
             if (dict.TryGetValue((allFields[i].FieldType.Name.GetHashCode() + allFields[i].Name.GetHashCode()).ToString(), out obj2))
             {
                 SharedVariable sharedVariable = TaskUtility.CreateInstance(allFields[i].FieldType) as SharedVariable;
                 sharedVariable.SetValue(JSONDeserialization.ValueToObject(task, allFields[i].FieldType, obj2, variableSource, unityObjects));
                 allFields[i].SetValue(obj, sharedVariable);
             }
             else
             {
                 SharedVariable sharedVariable2 = TaskUtility.CreateInstance(allFields[i].FieldType) as SharedVariable;
                 SharedVariable sharedVariable3 = allFields[i].GetValue(obj) as SharedVariable;
                 if (sharedVariable3 != null)
                 {
                     sharedVariable2.SetValue(sharedVariable3.GetValue());
                 }
                 allFields[i].SetValue(obj, sharedVariable2);
             }
         }
     }
 }