Inheritance: UnityEngine.ScriptableObject
示例#1
0
    public void SaveAllMesh(Texture2D img)
    {
        m_meshViewer_list.Clear();
        foreach (Transform child in meshViewer_list_go.transform)
        {
            m_meshViewer_list.Add(child.gameObject);
        }
        foreach (var gb in m_meshViewer_list)
        {
            Mesh mesh = gb.GetComponent <MeshFilter>().mesh;
            GenerateMeshUVMaps(gb, mesh, img);

            // Create Texture
            gb.GetComponent <MeshRenderer>().material = gb.GetComponent <MeshRenderer>().material;
            m_ImgPath = "Data_Image/Temp/" + m_ImgName;
            gb.GetComponent <MeshRenderer>().material.mainTexture = Resources.Load(m_ImgPath, typeof(Texture2D)) as Texture2D;
        }
        int i_inst = 0;

        foreach (var inst in m_meshViewer_list)
        {
            i_inst++;
            SavePrefab(inst, i_inst);
        }
        Selection.objects = m_meshViewer_list.ToArray();
        EditorObjExporter.ExportWholeSelectionToSingle();
        //EditorObjExporter.ExportEachSelectionToSingle(m_obj_path);
    }
    public void SaveAllMesh()
    {
        int i_inst = 0;

        foreach (var inst in m_meshViewer_best_list)
        {
            i_inst++;
            SavePrefab(inst, i_inst);
        }
        Selection.objects = m_meshViewer_best_list.ToArray();
        EditorObjExporter.ExportWholeSelectionToSingle();
        //EditorObjExporter.ExportEachSelectionToSingle(m_obj_path);
    }
    void exportMeshFilter(MeshFilter mf, string assetName)
    {
        EditorObjExporter.MeshToFile(mf, m_pathToAssets, assetName);

//		AssetDatabase.ImportAsset(m_pathToAssets + assetName + ".obj",ImportAssetOptions.ForceUpdate);
//		AssetDatabase.GenerateUniqueAssetPath(m_pathToAssets + assetName + ".obj");
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
        string filename   = m_pathToAssets.Substring(m_pathToAssets.LastIndexOf("Assets/")) + assetName + ".obj";
        Mesh   outputMesh = AssetDatabase.LoadAssetAtPath(filename, typeof(Mesh)) as Mesh;

        Debug.Log(" ### load path = " + m_pathToAssets + assetName + ".obj" + " success = " + (outputMesh != null));
        mf.mesh = outputMesh;
    }
示例#4
0
    public static string ExportOBJ(pb_Object[] pb)
    {
        if (pb.Length < 1)
        {
            return("");
        }

        pb_Object combined;

        if (pb.Length > 1)
        {
            pbMeshOps.CombineObjects(pb, out combined);
        }
        else
        {
            combined = pb[0];
        }

        // re-enable since CombineObjects sets all objs to disabled
        // foreach(pb_Object p in pb) {
        //  // blech!  shield your eyes!
        //  System.Type pbVB = Assembly.Load("Assembly-CSharp").GetTypes().First(t => t.Name == "pbVersionBridge");
        //  MethodInfo setActive = pbVB.GetMethod("SetActive");
        //  setActive.Invoke(null, new object[2]{p.gameObject, true});
        //  // p.MakeUnique();
        // }

        string path = EditorUtility.SaveFilePanel("Save ProBuilder Object as Obj", "", "pb" + pb[0].id + ".obj", "");

        if (path == null || path == "")
        {
            if (pb.Length > 1)
            {
                GameObject.DestroyImmediate(combined.GetComponent <MeshFilter>().sharedMesh);
                GameObject.DestroyImmediate(combined.gameObject);
            }
            return("");
        }
        EditorObjExporter.MeshToFile(combined.GetComponent <MeshFilter>(), path);
        AssetDatabase.Refresh();

        if (pb.Length > 1)
        {
            GameObject.DestroyImmediate(combined.GetComponent <MeshFilter>().sharedMesh);
            GameObject.DestroyImmediate(combined.gameObject);
        }
        return(path);
    }
示例#5
0
        public static string ExportOBJ(pb_Object[] pb)
        {
            if (pb.Length < 1)
            {
                return("");
            }

            pb_Object combined;

            if (pb.Length > 1)
            {
                pbMeshOps.CombineObjects(pb, out combined);
            }
            else
            {
                combined = pb[0];
            }

            string path = EditorUtility.SaveFilePanel("Save ProBuilder Object as Obj", "", "pb" + pb[0].id + ".obj", "");

            if (path == null || path == "")
            {
                if (pb.Length > 1)
                {
                    GameObject.DestroyImmediate(combined.GetComponent <MeshFilter>().sharedMesh);
                    GameObject.DestroyImmediate(combined.gameObject);
                }
                return("");
            }
            EditorObjExporter.MeshToFile(combined.GetComponent <MeshFilter>(), path);
            AssetDatabase.Refresh();

            if (pb.Length > 1)
            {
                GameObject.DestroyImmediate(combined.GetComponent <MeshFilter>().sharedMesh);
                GameObject.DestroyImmediate(combined.gameObject);
            }
            return(path);
        }
示例#6
0
    public void SaveAllMesh(Image <Rgb, byte> img)
    {
        foreach (var gb in m_meshViewer_list)
        {
            Mesh mesh = gb.GetComponent <MeshFilter>().mesh;
            GenerateMeshUVMaps(gb, mesh, img);

            // Create Texture
            gb.GetComponent <MeshRenderer>().material             = gb.GetComponent <MeshRenderer>().material;
            gb.GetComponent <MeshRenderer>().material.mainTexture = Resources.Load(m_ImgPath, typeof(Texture2D)) as Texture2D;
        }
        int i_inst = 0;

        foreach (var inst in m_meshViewer_list)
        {
            i_inst++;
            SavePrefab(inst, i_inst);
        }
        Selection.objects = m_meshViewer_list.ToArray();
        EditorObjExporter.ExportWholeSelectionToSingle();
        //EditorObjExporter.ExportEachSelectionToSingle(m_obj_path);
    }
示例#7
0
    void EditorArea()
    {
        GUILayout.BeginVertical();
        {
            GUILayout.BeginHorizontal();
            {
                geom_path_ = EditorGUILayout.TextField("输入模型文件(不带扩展名)", geom_path_);
                if (GUILayout.Button("加载", GUILayout.Width(130), GUILayout.Height(button_hight)))
                {
                    if (!CheckFileName(geom_path_))
                    {
                        return;
                    }
                    nav_editor.editor_geom_reload(root_paht_ + geom_path_);
                }
                if (GUILayout.Button("保存", GUILayout.Width(130), GUILayout.Height(button_hight)))
                {
                    if (!CheckFileName(geom_path_))
                    {
                        return;
                    }
                    nav_editor.editor_geom_save(root_paht_ + geom_path_);
                }
                if (GUILayout.Button("所选物件生成obj文件", GUILayout.Width(190), GUILayout.Height(button_hight)))
                {
                    if (!CheckFileName(geom_path_))
                    {
                        return;
                    }
                    bool ret = EditorObjExporter.ExportWholeSelectionToSingleObjFile(root_paht_ + geom_path_);
                    if (ret)
                    {
                        nav_editor.editor_geom_reload(root_paht_ + geom_path_);
                    }
                }
                if (GUILayout.Button("navmesh生成obj文件", GUILayout.Width(190), GUILayout.Height(button_hight)))
                {
                    if (!CheckFileName(geom_path_))
                    {
                        return;
                    }
                    NavmeshToMeshObj(root_paht_ + geom_path_);
                }
            }
            GUILayout.EndHorizontal();

            if (GUILayout.Button("生成导航网格", GUILayout.Width(130), GUILayout.Height(button_hight)))
            {
                int ret = nav_editor.editor_nav_mesh_build();
            }

            GUILayout.BeginHorizontal();
            {
                navmesh_path_ = EditorGUILayout.TextField("输入导航网格文件名(不带扩展名)", navmesh_path_);
                if (GUILayout.Button("加载", GUILayout.Width(130), GUILayout.Height(button_hight)))
                {
                    if (!CheckFileName(navmesh_path_))
                    {
                        return;
                    }
                    nav_editor.editor_load_nav_mesh(root_paht_ + navmesh_path_ + ".bin");
                }
                if (GUILayout.Button("保存", GUILayout.Width(130), GUILayout.Height(button_hight)))
                {
                    if (!CheckFileName(navmesh_path_))
                    {
                        return;
                    }
                    nav_editor.editor_save_nav_mesh(root_paht_ + navmesh_path_ + ".bin");
                }
            }
            GUILayout.EndHorizontal();
        }
        GUILayout.EndVertical();
    }
示例#8
0
    public override void OnInspectorGUI()
    {
        GUILayout.BeginVertical();
        {
            //--------------------------base-----------------------------------------------------
            GUILayout.BeginVertical();
            {
                EditorGUILayout.Space();
                file_name_ = EditorGUILayout.TextField("输入文件(不带扩展名)", file_name_);
                GUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button("加载", GUILayout.Width(130), GUILayout.Height(button_hight)))
                    {
                        if (!CheckFileName(file_name_))
                        {
                            return;
                        }
                        LoadFile(root_paht_ + file_name_);
                    }
                    if (GUILayout.Button("所选物件生成obj文件", GUILayout.Width(190), GUILayout.Height(button_hight)))
                    {
                        if (!CheckFileName(file_name_))
                        {
                            return;
                        }
                        bool ret = EditorObjExporter.ExportWholeSelectionToSingleObjFile(root_paht_ + file_name_);
                        if (ret)
                        {
                            LoadFile(root_paht_ + file_name_);
                        }
                    }
                }
                GUILayout.EndHorizontal();

                EditorGUILayout.Space();
                if (GUILayout.Button("生成导航网格", GUILayout.Width(130), GUILayout.Height(button_hight)))
                {
                    Build();
                }
                EditorGUILayout.Space();
                if (GUILayout.Button("保存", GUILayout.Width(130), GUILayout.Height(button_hight)))
                {
                    if (!CheckFileName(file_name_))
                    {
                        return;
                    }
                    SaveFile(root_paht_ + file_name_);
                }

                EditorGUILayout.Space();
                if (GUILayout.Button("清除", GUILayout.Width(130), GUILayout.Height(button_hight)))
                {
                    helper_.ClearRefreshNavmesh();
                }
            }
            GUILayout.EndVertical();

            //-------------------------tools-----------------------------------------------------
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            ToolType old_type = tool_type_;
            tool_type_ = (ToolType)EditorGUILayout.EnumPopup("编辑模式", tool_type_);
            if (tool_type_ == ToolType.Max)
            {
                tool_type_ = ToolType.None;
            }
            if (old_type != tool_type_)
            {
                tools_[(int)old_type].OnExit();
                tools_[(int)tool_type_].OnEnter();
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            tools_[(int)tool_type_].OnGUI();
        }
        GUILayout.EndVertical();
    }
 public void SaveOBJ(GameObject g, int i_inst)
 {
     Selection.activeGameObject = g;
     EditorObjExporter.ExportEachSelectionToSingle();
 }