Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Materials missing after runtime import in exported project #756

Open
KDouble48 opened this issue Feb 24, 2025 · 1 comment
Open

Materials missing after runtime import in exported project #756

KDouble48 opened this issue Feb 24, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@KDouble48
Copy link

Describe the bug
Materials are missing after a runtime import in an exported project.
Only in exported project. It works fine in the Unity Editor.

Files

New Blender Monkey with a material

To Reproduce
Steps to reproduce the behavior:

  1. Create new project
  2. Add new Script with code from the wiki:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GLTFast;

public class GLTFastTest : MonoBehaviour
{
    // Start is called before the first frame update
    async void Start()
    {
        // First step: load glTF
        var gltf = new GLTFast.GltfImport();
        // PATH TO GLB HERE
        var success = await gltf.Load("C:\\Users\\USER\\Documents\\untitled.glb");

        if (success) {
            // Here you can customize the post-loading behavior

            // Get the first material
            var material = gltf.GetMaterial();
            Debug.LogFormat("The first material is called {0}", material.name);

            // Instantiate the glTF's main scene
            await gltf.InstantiateMainSceneAsync( new GameObject("Instance 1").transform );
            // Instantiate the glTF's main scene
            await gltf.InstantiateMainSceneAsync( new GameObject("Instance 2").transform );

            // Instantiate each of the glTF's scenes
            for (int sceneId = 0; sceneId < gltf.SceneCount; sceneId++) {
                await gltf.InstantiateSceneAsync(transform, sceneId);
            }
        } else {
            Debug.LogError("Loading glTF failed!");
        }
    }
}
  1. Start in Editor; everything works as expected
  2. Build Project
  3. Start exe
  4. Monkey will not be instantiated as material will be null and throw a NullReferenceException

Expected behavior
Exported Project should behave the same as in Unity Editor

Desktop:

  • glTFast version: 6.10.1
  • Unity Editor version: 2022.3.0f1
  • Render Pipeline: Built-In render pipeline
  • Platform: Windows Player
@KDouble48 KDouble48 added the bug Something isn't working label Feb 24, 2025
@KDouble48 KDouble48 changed the title Materials missing in after runtime import in exported project Materials missing after runtime import in exported project Feb 24, 2025
@KDouble48
Copy link
Author

I tried to run the same steps on 6.8.0 (as an older version of my choice) and it works as expected without any further changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant