Skip to content

MetaAlms/GLTFUtility

This branch is 7 commits behind Siccity/GLTFUtility:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

96619fc · Dec 7, 2022
Dec 15, 2021
Nov 15, 2021
Mar 16, 2022
Nov 15, 2021
Sep 13, 2019
Oct 18, 2020
Sep 23, 2020
Aug 8, 2019
Oct 11, 2018
Aug 7, 2019
Apr 1, 2019
Sep 23, 2020
Dec 7, 2022
Aug 7, 2019
Oct 10, 2018
Mar 25, 2021
Apr 8, 2019

Repository files navigation

Discord GitHub issues GitHub license

GLTFUtility

Allows you to import and export glTF files during runtime and in editor. glTF is a new opensource 3d model transmission format which supports everything you'll ever need from a format in Unity. Read more about glTF here

2019-04-01_00-46-27 image image

What makes GLTFUtility different?

Focusing on simplicity and ease of use, GLTFUtility aims to be an import-and-forget solution, keeping consistency with built-in functionality.

Installation

Using Unity Package Manager (Help)
  1. "com.siccity.gltfutility": "https://github.com/siccity/gltfutility.git"
Using git
  1. Get Newtonsoft.JSON from one of these sources
  2. Clone GLTFUtility by itself or as a submodule
    • Clone into your assets folder git clone [email protected]:Siccity/GLTFUtility.git
    • Add repo as submodule git submodule add [email protected]:Siccity/GLTFUtility.git Assets/Submodules/GLTFUtility
Manual download
  1. Get Newtonsoft.JSON from the asset store
  2. Download GLTFUtility-master.zip and extract to your project assets

Important notice

Features

System

  • Editor import
  • Editor export
  • Runtime import API
  • Runtime export API
  • GLTF format
  • GLB format
  • Multithreading
  • URP #75
  • HDRP #73
  • LWRP

Spec

  • Static mesh (with submeshes)
  • UVs (up to 8 channels)
  • Normals
  • Tangents
  • Vertex colors
  • Materials (metallic/specular, opaque/mask/blend)
  • Textures (embedded/external)
  • Remote textures (during async only)
  • Rig
  • Avatar/Mask #70
  • Animations (multiple)
  • Morph targets (with experimental names)
  • Cameras

Extensions

  • KHR_texture_transform (partial support)
  • KHR_materials_pbrSpecularGlossiness
  • KHR_lights_punctual #25
  • KHR_draco_mesh_compression #27 WARNING: Said to cause issues on WebGL.
  • KHR_mesh_quantization

Known issues

  • ArgumentNullException: Value cannot be null in build but not in editor.
    • This is most likely due to shaders being stripped from the build. To fix this, add the GLTFUtility shaders to the Always Included Shaders list in Graphic Settings.
  • Draco compression does not work on iOS and UWP

Runtime import API

// Single thread
using Siccity.GLTFUtility;

void ImportGLTF(string filepath) {
   GameObject result = Importer.LoadFromFile(filepath);
}
// Multithreaded
using Siccity.GLTFUtility;

void ImportGLTFAsync(string filepath) {
   Importer.ImportGLTFAsync(filepath, new ImportSettings(), OnFinishAsync);
}

void OnFinishAsync(GameObject result, AnimationClip[] animations) {
   Debug.Log("Finished importing " + result.name);
}

Important shader note

To ensure that Unity includes the GLTFUtility shaders in builds, you must add these shaders to the 'Always Included Shaders' list.

  1. Open Edit -> Project Settings
  2. Open Graphics
  3. Scroll to Always Included Shaders
  4. Under Size, increase the value by 4 and hit Enter.
  5. In the Project panel, navigate to Packages/GLTFUtility/Materials/Built-in.
  6. In this directory are 4 .shader files.
  7. Drag and drop each of the 4 files into one of the 4 newly created rows in Always Included Shaders.

About

Simple GLTF importer for Unity

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 94.1%
  • ShaderLab 5.9%