Esempio n. 1
0
    // MQOファイルをUnity形式に変換
    void BurnUnityFormatForMQO(Root.MQO.MQOFormat format)
    {
        Root_obj      = new GameObject(format.name);
        format.caller = Root_obj;

        if (format.haveMaterial == true)
        {
            Root.MQO.MQOConverter conv = new Root.MQO.MQOConverter();

            this.meshes = conv.CreateMeshes(format);
            Debug.Log("Maked meshes");

            this.materials = conv.CreateMaterials(format);
            Debug.Log("Maked materials");

            //Object prefab = UnityEditor.PrefabUtility.CreateEmptyPrefab(format.folder + "/" + format.name + ".prefab");
            GameObject[] child = new GameObject[format.object_list.obj_count];
            for (int obj_id = 0; obj_id < format.object_list.obj_count; obj_id++)
            {
                child[obj_id] = new GameObject(format.object_list.obj[obj_id].obj_name);
                conv.ReplaceObject(format, obj_id, child[obj_id], meshes[obj_id], materials);
                child[obj_id].transform.parent = Root_obj.transform;
            }
            Debug.Log("Comp Prefab");

            /*Object[] prefab = new Object[format.object_list.obj_count];
             * for(int t = 0 ; t < format.object_list.obj_count; t++) {
             *      prefab[t] = EditorUtility.CreateEmptyPrefab(format.folder + "/" + format.object_list.obj[t].obj_name + ".prefab");
             *      EditorUtility.ReplacePrefab(child[t], prefab[t], ReplacePrefabOptions.ConnectToPrefab);
             * }*/
            Object Root_Prefab = EditorUtility.CreateEmptyPrefab(format.folder + "/" + format.name + ".prefab");
            EditorUtility.ReplacePrefab(Root_obj, Root_Prefab, ReplacePrefabOptions.ConnectToPrefab);
        }
        else
        {
            Debug.Log("Error:There aren't Material");
        }
        EndOfScript(format);
    }    //*/
    // MQOファイルをUnity形式に変換
    void BurnUnityFormatForMQO(Root.MQO.MQOFormat format)
    {
        Root_obj = new GameObject(format.name);
        format.caller = Root_obj;

        if(format.haveMaterial == true)
        {
            Root.MQO.MQOConverter conv = new Root.MQO.MQOConverter();

            this.meshes = conv.CreateMeshes(format);
            Debug.Log("Maked meshes");

            this.materials = conv.CreateMaterials(format);
            Debug.Log("Maked materials");

            //Object prefab = UnityEditor.PrefabUtility.CreateEmptyPrefab(format.folder + "/" + format.name + ".prefab");
            GameObject[] child = new GameObject[format.object_list.obj_count];
            for(int obj_id = 0;obj_id < format.object_list.obj_count; obj_id++)
            {
                child[obj_id] = new GameObject(format.object_list.obj[obj_id].obj_name);
                conv.ReplaceObject(format , obj_id ,child[obj_id] ,meshes[obj_id] ,materials);
                child[obj_id].transform.parent = Root_obj.transform;
            }
            Debug.Log("Comp Prefab");

            /*Object[] prefab = new Object[format.object_list.obj_count];
            for(int t = 0 ; t < format.object_list.obj_count; t++) {
                prefab[t] = EditorUtility.CreateEmptyPrefab(format.folder + "/" + format.object_list.obj[t].obj_name + ".prefab");
                EditorUtility.ReplacePrefab(child[t], prefab[t], ReplacePrefabOptions.ConnectToPrefab);
            }*/
            Object Root_Prefab = EditorUtility.CreateEmptyPrefab(format.folder + "/" + format.name + ".prefab");
            EditorUtility.ReplacePrefab(Root_obj, Root_Prefab, ReplacePrefabOptions.ConnectToPrefab);
        }
        else
            Debug.Log("Error:There aren't Material");
        EndOfScript(format);
    }