Skip to content

Commit

Permalink
Now with (very basic) texture loading support !
Browse files Browse the repository at this point in the history
Since the Blender add-on now exports UV correctly,
I can provide the ability to load one texture and
apply it on the only one material used.

Multiple materials support is on its way, but
for the moment, you'll have to bear with only
one texture.

Signed-off-by: Voyage <[email protected]>
  • Loading branch information
vr-voyage committed May 23, 2023
1 parent 1bce524 commit 7435899
Show file tree
Hide file tree
Showing 13 changed files with 4,348 additions and 2,271 deletions.
4,883 changes: 3,132 additions & 1,751 deletions Runtime/Prefab/ModelLoader.prefab

Large diffs are not rendered by default.

112 changes: 26 additions & 86 deletions Runtime/Scripts/ModelImporterPanel.asset
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: ModelImporterPanel
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: 84203e193a04fe4478e5a868e8214871,
serializedUdonProgramAsset: {fileID: 11400000, guid: 3edb98da738885c4e9d5fa701a30ad3b,
type: 2}
udonAssembly:
assemblyError:
Expand Down Expand Up @@ -44,7 +44,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 11
Data: 10
- Name:
Entry: 7
Data:
Expand Down Expand Up @@ -392,31 +392,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: modelImporter
Data: statusText
- Name: $v
Entry: 7
Data: 17|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: modelImporter
Data: statusText
- Name: <UserType>k__BackingField
Entry: 7
Data: 18|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VoyageVRSNS.ModelsImporter, io.github.vr-voyage.direct-model-importer
- Name:
Entry: 8
Data:
Entry: 9
Data: 3
- Name: <SystemType>k__BackingField
Entry: 7
Data: 19|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
Entry: 9
Data: 3
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
Expand All @@ -431,7 +419,7 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 20|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
Expand All @@ -452,73 +440,31 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: modelUrlInput
Data: modelImporter
- Name: $v
Entry: 7
Data: 21|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: modelUrlInput
Data: modelImporter
- Name: <UserType>k__BackingField
Entry: 7
Data: 22|System.RuntimeType, mscorlib
Data: 20|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Components.VRCUrlInputField, VRCSDK3
Data: VoyageVRSNS.ModelsImporter, io.github.vr-voyage.direct-model-importer
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 22
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
Data: 21|System.RuntimeType, mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 23|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: textureUrlInput
- Name: $v
Entry: 7
Data: 24|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: textureUrlInput
- Name: <UserType>k__BackingField
Entry: 9
Data: 22
- Name: <SystemType>k__BackingField
Entry: 9
Data: 22
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
Expand All @@ -533,7 +479,7 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 25|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 22|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
Expand All @@ -554,25 +500,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: emptyUrl
Data: modelUrlInput
- Name: $v
Entry: 7
Data: 26|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 23|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: emptyUrl
Data: modelUrlInput
- Name: <UserType>k__BackingField
Entry: 7
Data: 27|System.RuntimeType, mscorlib
Data: 24|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDKBase.VRCUrl, VRCSDKBase
Data: VRC.SDK3.Components.VRCUrlInputField, VRCSDK3
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 27
Data: 24
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
Expand All @@ -587,16 +533,10 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 28|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 25|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 29|UnityEngine.HideInInspector, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
Data: 0
- Name:
Entry: 13
Data:
Expand Down
21 changes: 10 additions & 11 deletions Runtime/Scripts/ModelImporterPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@ public class ModelImporterPanel : UdonSharpBehaviour
public TMPro.TextMeshProUGUI uvsText;
public TMPro.TextMeshProUGUI indicesText;
public TMPro.TextMeshProUGUI debugText;
public TMPro.TextMeshProUGUI statusText;

public VoyageVRSNS.ModelsImporter modelImporter;
public VRCUrlInputField modelUrlInput;
public VRCUrlInputField textureUrlInput;

[HideInInspector]
public VRCUrl emptyUrl;

public void ResetDisplay()
{
DisplayText(downloadedUrlText, "");
Expand All @@ -36,6 +33,7 @@ public void ResetDisplay()
DisplayText(uvsText, "");
DisplayText(indicesText, "");
DisplayText(debugText, "");
DisplayText(statusText, "");
}

void DisplayText(TMPro.TextMeshProUGUI uiText, string content)
Expand Down Expand Up @@ -66,10 +64,16 @@ public void ShowValues(
DisplayText(debugText, additionalContent);
}

public void ShowStatus(string statusMessage)
{
DisplayText(statusText, statusMessage);
}

public void ModelDownloaded()
{
Debug.Log("Model Downloaded !");
if (modelUrlInput == null) return;
modelUrlInput.SetUrl(emptyUrl);
modelUrlInput.SetUrl(VRCUrl.Empty);
}

public void DownloadButtonPushed()
Expand All @@ -78,15 +82,10 @@ public void DownloadButtonPushed()
if (modelImporter.isDownloading) return;

VRCUrl modelUrl = modelUrlInput.GetUrl();
VRCUrl textureUrl = null;
if (textureUrlInput != null)
{
textureUrl = textureUrlInput.GetUrl();
}

Debug.Log($"Trying to download : {modelUrl}");

modelImporter.DownloadModel(modelUrl, new VRCUrl[] { textureUrl });
modelImporter.DownloadModel(modelUrl);
}
}
}
Expand Down
Loading

0 comments on commit 7435899

Please sign in to comment.