Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Move export menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ousttrue committed Jul 23, 2018
1 parent eb12aea commit 38316c4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 39 deletions.
10 changes: 8 additions & 2 deletions Core/Scripts/IO/gltfExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace UniGLTF
{
public class gltfExporter : IDisposable
{
const string CONVERT_HUMANOID_KEY = "GameObject/gltf/export";
const string CONVERT_HUMANOID_KEY = UniGLTFVersion.UNIGLTF_VERSION + "/Export";

#if UNITY_EDITOR
[MenuItem(CONVERT_HUMANOID_KEY, true, 1)]
Expand Down Expand Up @@ -43,6 +43,12 @@ private static void ExportFromMenu()
}
var bytes = gltf.ToGlbBytes();
File.WriteAllBytes(path, bytes);

if (path.StartsWithUnityAssetPath())
{
AssetDatabase.ImportAsset(path.ToUnityRelativePath());
AssetDatabase.Refresh();
}
}
#endif

Expand Down Expand Up @@ -622,7 +628,7 @@ public static Exported FromGameObject(glTF gltf, GameObject go, bool useSparseAc

if (go.transform.childCount == 0)
{
throw new UniGLTFException("root node required");
throw new UniGLTFException("empty root GameObject required");
}

var unityNodes = go.transform.Traverse()
Expand Down
75 changes: 38 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,66 +9,67 @@
![duck_prefab](doc/duck_prefab.png)
![animation](doc/animation.gif)

* [Samples](https://github.com/ousttrue/UniGLTF_Test)
* [Sample and Tests](https://github.com/ousttrue/UniGLTF_Test)
* [Humanoid Helper](https://github.com/ousttrue/UniHumanoid)
* [Json backend](https://github.com/ousttrue/UniJson)

## License
# License

* [MIT license](LICENSE)

## Download
# Sample Models

* https://github.com/ousttrue/UniGLTF/releases

## Install

* import [unitypackage](https://github.com/ousttrue/UniGLTF/releases)

## Usage

* drop gltf folder or glb file into Assets folder

or
* https://github.com/KhronosGroup/glTF-Sample-Models

* menu [Assets] - [gltf] - [import]
Exclude SciFiHelmet(70074vertices), all model can import.

## Importer
[Mesh.IndexFormat(from 2017.3)](https://docs.unity3d.com/ScriptReference/Mesh-indexFormat.html) allows a huge mesh, Otherwise mesh division required.

* [x] asset(ScriptedImporter) (Unity-2017 or new)
* [x] asset(AssetPostprocessor.OnPostprocessAllAssets) (Unity-5.6)
![SciFiHelmet](doc/SciFiHelmet.png)

* runtime [Assets] - [gltf] - [import]
# Download

### Sample Models
* https://github.com/ousttrue/UniGLTF/releases

* https://github.com/KhronosGroup/glTF-Sample-Models
## Install

Exclude SciFiHelmet(70074vertices), all model can import.
* import [unitypackage](https://github.com/ousttrue/UniGLTF/releases)

[Mesh.IndexFormat(from 2017.3)](https://docs.unity3d.com/ScriptReference/Mesh-indexFormat.html) allows a huge mesh, Otherwise mesh division required.
# Usage

![SciFiHelmet](doc/SciFiHelmet.png)
## Import as asset

### Can load gltf in zip archive
* drop gltf folder or glb file into Assets folder

* https://github.com/ousttrue/UniGLTF_Test/blob/master/Assets/UniGLTF.Samples/LoaderFromHttp/LoadFromHttp.cs
or

## Exporter
* menu [UniGLTF] - [Import] (select out of Asset folder gltf file(gltf, glb, zip) and (save into Asset folder)

* asset([right click] - [gltf] - [export]
* runtime
* [validation](http://github.khronos.org/glTF-Validator/)
## Import in runTime

## Experimental ScriptedImporter for Unity2017
```cs
var path; // gltf, glb or zip(include gltf)
[ScriptedImporter](https://docs.unity3d.com/ScriptReference/Experimental.AssetImporters.ScriptedImporter.html)
var context = gltfImporter.Load(path);
context.ShowMeshes();

* Unity2017.3.0f3
GameObject root = context.Root;
```

![duck_assets](doc/duck_assets.png)
## Export from scene

ScriptedImporter removed.
* menu [UniGLTF] - [Export]

## Humanoid Helper
## Import in runTime

* move to [UniHumanoid](https://github.com/ousttrue/UniHumanoid)
```cs
var gltf = new glTF();
using (var exporter = new gltfExporter(gltf))
{
exporter.Prepare(go);
exporter.Export();
}
var bytes = gltf.ToGlbBytes();
File.WriteAllBytes(path, bytes);
```

0 comments on commit 38316c4

Please sign in to comment.