Skip to content

Commit

Permalink
发布1.0.0版本
Browse files Browse the repository at this point in the history
  • Loading branch information
monitor1394 committed Oct 29, 2019
1 parent a8f140e commit 18413bf
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 更新日志

* (2019.10.29) 增加`Package Manager`包安装模式支持
Binary file added Documentation/screenshot/export.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/screenshot/part.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/screenshot/scene.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/screenshot/select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 10 additions & 11 deletions ExportScene.cs → Editor/ExportScene.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using System.Collections;
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/

using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;

/// <summary>
/// 导出场景(包括GameObject和Terrian)到.obj文件,支持自定义裁剪区域导出和自动裁剪导出
///
/// author by monitor1394@gmail.com
///
/// </summary>
public class ExportScene : EditorWindow
{
private const string CUT_LB_OBJ_PATH = "export/bound_lb";
Expand Down Expand Up @@ -92,7 +91,7 @@ public static void ExportSceneToObj(string path, Terrain terrain, MeshFilter[] m
foreach (var mf in mfs)
{
UpdateProgress(title);
if (mf.GetComponent<Renderer>() != null &&
if (mf.GetComponent<Renderer>() != null &&
(!needCheckRect || (needCheckRect && IsInCutRect(mf.gameObject))))
{
ExportMeshToObj(mf.gameObject, mf.sharedMesh, ref writer, ref vertexOffset);
Expand Down Expand Up @@ -128,9 +127,9 @@ private static void OpenDir(string path)
OpenCmd("explorer.exe", dir.FullName);
}

private static void OpenCmd(string cmd,string args)
private static void OpenCmd(string cmd, string args)
{
System.Diagnostics.Process.Start(cmd,args);
System.Diagnostics.Process.Start(cmd, args);
}

private static string GetSavePath(bool autoCut, GameObject selectObject)
Expand Down
File renamed without changes.
43 changes: 33 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,57 @@

# ExportSceneToObj
`ExportSceneToObj`是用于导出`Unity`场景(包括`GameObject``Terrian`)到`.obj`文件的`Editor`脚本,也支持导出`.fbx`模型到`.obj`

### 功能:
一款用于导出场景(包括`GameObject``Terrian`)或到`.fbx`模型`.obj`文件的`Unity`插件。

## 功能

* 支持导出物件和地形
* 支持自定义裁剪区域
* 支持自动裁剪功能
* 支持单个选择导出
* 支持导出`.fbx`模型

### 用法:
*`ExportScene.cs`脚本放到你项目的`Assets`/`Editor`目录下
## 截图

<img src="Documentation/screenshot/scene.png" width="1000" height="auto"/>
<img src="Documentation/screenshot/export.png" width="1000" height="auto"/>
<img src="Documentation/screenshot/part.png" width="1000" height="auto"/>
<img src="Documentation/screenshot/select.png" width="1000" height="auto"/>

## 用法

* 通过下载源码或`unitypackage`包导入到你的项目中(放在`Assets`目录下)。如果你是`2018.3`及以上版本,强烈建议通过`Package Manager``Git`来导入包(也可以下载后本地安装包):

1. 打开`Packages`目录下的`manifest.json`文件,在`dependencies`下加入:
``` json
"com.monitor1394.exportscenetoobj": "https://github.com/monitor1394/ExportSceneToObj.git",
```
2. 回到`Unity`,可能会花1分钟左右进行下载和编译,成功后就可以开始使用了。
3. 如果要删除`ExportSceneToObj`,删除掉1步骤所加的内容即可。
4. 如果要更新`ExportSceneToObj`,删除`manifest.json`文件的`lock`下的`com.monitor1394.exportscenetoobj`相关内容即会从新下载编译。

* 如果要自定义裁剪区域的话,场景中增加空`GameObject`用于表示裁剪区域(需要左下角和右上角两个空`GameObject`),并修改代码中`CUT_LB_OBJ_PATH``CUT_RT_OBJ_PATH`为对应的路径
*`Unity`的菜单栏上有`ExportScene`菜单即可
* 怎么单独导出`.fbx`模型?
1.`.fbx`拖到场景中
2.`Hierarchy`试图中选中`fbx``GameObject`,右键执行`ExportScene` --> `ExportSelectedObj`单独导出即可

### 其他:
## 其他

1. 目前判断物件是否在裁剪区域只是判断物件的坐标是否在区域内,还没有实现物件边界裁剪。
2. 只有包含`MeshFilter``SkinnedMeshRenderer``Terrian`的物件才会被导出
2. 只有包含`MeshFilter``SkinnedMeshRenderer``Terrian`的物件才会被导出。

## 问题

### 问题:
1. 为什么将脚本放入项目中后菜单栏还是看不到`ExportScene`菜单项?
答:脚本文件放到正确的目录,同时要检查是否有其他脚本有报错没有编译通过,有报错时先要处理报错。

2. 为什么导出的`obj`文件在`Maya``3D`软件中显示正常,但在`3d Max`显示异常?
答:`3d Max`导入设置中勾选`Import as single mesh`选项。

### 觉得有用的朋友帮忙点个star吧

### 参考:
## 觉得有用的朋友帮忙点个star吧

## 参考

1. [ExportOBJ](http://wiki.unity3d.com/index.php?title=ExportOBJ)
2. [TerrainObjExporter](http://wiki.unity3d.com/index.php?title=TerrainObjExporter)
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "com.monitor1394.exportscenetoobj",
"displayName": "Export Scene To Obj",
"version": "1.0.0",
"unity": "2018.3",
"description": "Export scene (including objects and terrain ) or fbx to .obj file for Unity.",
"keywords": [
"unity",
"export",
"scene",
"terrain",
"obj",
"fbx"
],
"category": "editor",
"repository": {
"type": "git",
"url": "git+https://github.com/monitor1394/ExportSceneToObj.git"
},
"author": "monitor1394",
"license": "MIT",
"bugs": {
"url": "https://github.com/monitor1394/ExportSceneToObj/issues"
},
"homepage": "https://github.com/monitor1394/ExportSceneToObj"
}

0 comments on commit 18413bf

Please sign in to comment.