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

Editor importer broken in Unity 2021 - textures missing on models #218

Open
stetttho opened this issue Sep 22, 2022 · 0 comments
Open

Editor importer broken in Unity 2021 - textures missing on models #218

stetttho opened this issue Sep 22, 2022 · 0 comments

Comments

@stetttho
Copy link

After updating from Unity 2020 to 2021, on our gltf models the textures were missing. Seems to be a problem with Unity Method AssetDatabase.LoadAssetAtPath only accepting relative paths (like "Assets/xyz/model.gltf") and no full path anymore.

I fixed it temporarily by changing the method CreateTextureAsync in GLTFImage.cs:

public IEnumerator CreateTextureAsync(bool linear, Action<Texture2D> onFinish, Action<float> onProgress = null) {
				if (!string.IsNullOrEmpty(path)) {
					string relativePath = path.Substring(path.IndexOf("Assets")); // get relative path and then pass it below
#if UNITY_EDITOR
					// Load textures from asset database if we can
					Texture2D assetTexture = UnityEditor.AssetDatabase.LoadAssetAtPath(relativePath, typeof(Texture2D)) as Texture2D;
					if (assetTexture != null) {
						onFinish(assetTexture);
						if (onProgress != null) onProgress(1f);
						yield break;
					}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant