public void registerGameObjectData(GameObject gameObj)
        {
            if (!gameObj)
            {
                return;
            }

            JsonGameObject.registerLinkedData(gameObj, this);
            foreach (Transform child in gameObj.transform)
            {
                if (!child)
                {
                    continue;
                }
                if (!child.gameObject)
                {
                    registerGameObjectData(child.gameObject);
                }
            }
        }
Example #2
0
        public JsonPrefabData(GameObject prefabObject, ResourceMapper resMap)
        {
            id = resMap.getRootPrefabId(prefabObject, true);

            path = AssetDatabase.GetAssetPath(prefabObject);
            guid = AssetDatabase.AssetPathToGUID(path);
            //name = System.IO.Path.GetFileName(path);
            name = prefabObject.name;            //looks like name of prefab mirrors that of a file, sans extension
            //prefabType = PrefabUtility.GetPrefabType(prefabObject).ToString();
            prefabAssetType      = PrefabUtility.GetPrefabAssetType(prefabObject).ToString();
            prefabInstanceStatus = PrefabUtility.GetPrefabInstanceStatus(prefabObject).ToString();

            var mapper = resMap.getPrefabObjectMapper(prefabObject);

            for (int i = 0; i < mapper.numObjects; i++)
            {
                ///Well, this is certainly not the best way to go about it...
                var src = mapper.getObjectByIndex(i);
                var dst = new JsonGameObject(src, mapper, resMap);
                objects.Add(dst);
            }
        }
Example #3
0
        public static JsonScene fromObjects(GameObject[] args, ResourceMapper resMap, bool showGui)
        {
            try{
                var result = new JsonScene();

                var objMap = new GameObjectMapper();
                foreach (var curObj in args)
                {
                    objMap.gatherObjectIds(curObj);
                }

                foreach (var curObj in objMap.objectList)
                {
                    resMap.gatherPrefabData(curObj);
                }

                for (int i = 0; i < objMap.objectList.Count; i++)
                {
                    /*TODO: The constructor CAN add more data, but most of it would've been added prior to this point.
                     * Contempalting whether to enforce it strictly or not.*/
                    if (showGui)
                    {
                        ExportUtility.showProgressBar("Collecting scene data",
                                                      string.Format("Adding scene object {0}/{1}", i, objMap.numObjects), i, objMap.objectList.Count);
                    }

                    var newObj = new JsonGameObject(objMap.objectList[i], objMap, resMap);
                    result.objects.Add(newObj);
                }
                return(result);
            }
            finally{
                if (showGui)
                {
                    ExportUtility.hideProgressBar();
                }
            }
        }