Example #1
0
        public ContentCachedTurretAssemblyPrefab(RootModel model)
        {
            TurretAssemblyAssembler assembler = new TurretAssemblyAssembler();
            GameObject instance = assembler.Assemble(model).gameObject;

            _cache = new SceneCachedGameObject(instance);
        }
        private void LoadFile(string path)
        {
            if (CurrentAsssembly)
            {
                DeleteCurrentAssembly();
            }

            var json  = JObject.Parse(File.ReadAllText(path));
            var model = ObjectPipeline.DeserializeObject(json);

            TurretAssemblyAssembler assembler = new TurretAssemblyAssembler();

            CurrentAsssembly = assembler.Assemble(model);

            if (CurrentAsssembly is Component comp)
            {
                comp.transform.position = Vector3.zero;
                comp.transform.rotation = Quaternion.identity;
            }

            NameText.text        = CurrentAsssembly.Name;
            DescriptionText.text = CurrentAsssembly.Description;
        }