Esempio n. 1
0
        public override void OnLoad()
        {
            AssetBundle ab       = LoadAssets.LoadBundle(this, "cinderblocks.unity3d");
            GameObject  original = ab.LoadAsset <GameObject>("cinderblock.prefab");

            _block       = GameObject.Instantiate <GameObject>(original);
            _block.name  = "cinder block";
            _block.tag   = "PART";
            _block.layer = LayerMask.NameToLayer("Parts");
            _block.GetComponent <Rigidbody>().isKinematic = true;

            GameObject.Destroy(original);
            ab.Unload(false);

            // Load save

            CinderBlocksSaveData data = CinderBlocksSaveData.Deserialize <CinderBlocksSaveData>(CinderBlocksSaveData.SavePath);

            for (int i = 0; i < data.Pos.Count; ++i)
            {
                GameObject cinderblock = GameObject.Instantiate <GameObject>(_block);
                cinderblock.transform.position = data.Pos[i];
                cinderblock.transform.rotation = data.Rot[i];
            }

            // Initialize
            if (data.Pos.Count <= 0)
            {
                InitSpawn();
            }
        }
Esempio n. 2
0
 public override void OnSave()
 {
     {
         CinderBlocksSaveData data = new CinderBlocksSaveData(new List <Vector3>(), new List <Quaternion>());
         foreach (GameObject obj in GameObject.FindObjectsOfType <GameObject>())
         {
             if (obj.name == "cinder block(Clone)")
             {
                 data.Pos.Add(obj.transform.position);
                 data.Rot.Add(obj.transform.rotation);
             }
         }
         CinderBlocksSaveData.Serialize(data, CinderBlocksSaveData.SavePath);
     }
 }