コード例 #1
0
    public static void LoadObject(StringReaderEx str, GameObject obj)
    {
        Component[] components = obj.GetComponents <Component>();
        Dictionary <string, Component> byName = new Dictionary <string, Component>();

        foreach (Component c in components)
        {
            byName[c.GetType().Name] = c;
        }

        bool isActive = str.ReadLineBool();

        int len = str.ReadLineInt();

        for (int i = 0; i < len; i++)
        {
            string name    = str.ReadLine();
            bool   enabled = str.ReadLineBool();
            if (byName.ContainsKey(name))
            {
                Component c = byName[name];
                if (c is Behaviour)
                {
                    (c as Behaviour).enabled = enabled;
                }

                LoadComponent(str, c);
                //LoadClass<Component>(str,c);
            }
        }

        obj.SetActive(isActive);
    }
コード例 #2
0
        public override void Load(StringReaderEx str, object obj)
        {
            Rigidbody2D r = obj as Rigidbody2D;

            r.isKinematic  = str.ReadLineBool();
            r.gravityScale = str.ReadLineFloat();
        }