Пример #1
0
        public void loadScene(GameObject defaultObject, ConfigReader config)
        {
            index = 0;
            UnityEngine.Object[] listObjects;

            //Instantiate list
            list = new List <Model>();
            //Get configuration nodes using litJSON


            listObjects = FileLoader.getObjects();

            foreach (GameObject listObject in listObjects)
            {
                Model model;
                //Instantiate game object. Maybe we're just a step away to make this one visible, but I can't find it so just re create it...
                GameObject obj = (GameObject)GameObject.Instantiate(listObject, Vector3.zero, Quaternion.identity);

                ConfNode node = Array.Find(config.Nodes, element => obj.name.Equals(element.name + "(Clone)", StringComparison.OrdinalIgnoreCase));
                model = new Model(obj, node);
                model.setActive(false);
                list.Add(model);
            }
            if (list.Count > 0)
            {
                this.setCurrent(0);
            }
            else if (defaultObject != null)
            {
                list.Add(new Model((GameObject)GameObject.Instantiate(defaultObject, Vector3.zero, Quaternion.identity)));
                this.setCurrent(0);
            }
        }
Пример #2
0
 public Model(GameObject mesh, ConfNode config)
 {
     if (config != null)
     {
         this.conf = config;
     }
     this.init(mesh);
 }
Пример #3
0
 public void init(GameObject mesh)
 {
     if (this.conf == null)
     {
         this.conf = new ConfNode(mesh.name);
     }
     this.attachedComponents = new List <GameObject>();
     this.obj    = mesh;
     this.bounds = GetMeshHierarchyBounds(this.obj);
     this.scale();
     this.center();
     if (this.conf != null && this.conf.objects != null)
     {
         foreach (string name in this.conf.objects)
         {
             GameObject target = GameObject.Find(name);
             if (target != null)
             {
                 this.attachedComponents.Add(target);
             }
         }
     }
 }
Пример #4
0
 public Model(GameObject mesh)
 {
     conf = new ConfNode(mesh.name);
     this.init(mesh);
 }