胡佳骏 1 year ago
parent
commit
9b42a9fa79
1 changed files with 9 additions and 9 deletions
  1. 9 9
      Samples~/trilibSDK/TriLibModelLoad.cs

+ 9 - 9
Samples~/trilibSDK/TriLibModelLoad.cs

@@ -6,7 +6,7 @@ using TriLibCore.Utils;
 using UnityEngine;
 
 public class TriLibModelLoad
-{ 
+{
 
     /// <summary>
     /// Creates the AssetLoaderOptions instance, configures the Web Request, and downloads the Model.
@@ -14,30 +14,30 @@ public class TriLibModelLoad
     /// <remarks>
     /// You can create the AssetLoaderOptions by right clicking on the Assets Explorer and selecting "TriLib->Create->AssetLoaderOptions->Pre-Built AssetLoaderOptions".
     /// </remarks>
-    public static void Load(string ModelURL, Action<AssetLoaderContext> OnLoad, Action<AssetLoaderContext> OnMaterialsLoad, Action<AssetLoaderContext, float> OnProgress, Action<IContextualizedError> OnError)
+    public static void Load(string ModelURL, Action<AssetLoaderContext> OnLoad, Action<AssetLoaderContext> OnMaterialsLoad, Action<AssetLoaderContext, float> OnProgress, Action<IContextualizedError> OnError, GameObject go = null)
     {
-        if(ModelURL.Contains("http"))
+        if (ModelURL.Contains("http"))
         {
-            loadUrl( ModelURL,  OnLoad,  OnMaterialsLoad,  OnProgress, OnError);
+            loadUrl(ModelURL, OnLoad, OnMaterialsLoad, OnProgress, OnError, go);
         }
         else
         {
-            loadFile(ModelURL, OnLoad, OnMaterialsLoad, OnProgress, OnError);
+            loadFile(ModelURL, OnLoad, OnMaterialsLoad, OnProgress, OnError, go);
         }
 
     }
-    static void loadUrl(string ModelURL, Action<AssetLoaderContext> OnLoad, Action<AssetLoaderContext> OnMaterialsLoad, Action<AssetLoaderContext, float> OnProgress, Action<IContextualizedError> OnError)
+    static void loadUrl(string ModelURL, Action<AssetLoaderContext> OnLoad, Action<AssetLoaderContext> OnMaterialsLoad, Action<AssetLoaderContext, float> OnProgress, Action<IContextualizedError> OnError, GameObject go = null)
     {
         var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();
         var webRequest = AssetDownloader.CreateWebRequest(ModelURL);
-        AssetDownloader.LoadModelFromUri(webRequest, OnLoad, OnMaterialsLoad, OnProgress, OnError, null, assetLoaderOptions);
+        AssetDownloader.LoadModelFromUri(webRequest, OnLoad, OnMaterialsLoad, OnProgress, OnError, go, assetLoaderOptions);
 
     }
 
-    static void loadFile(string ModelPath, Action<AssetLoaderContext> OnLoad, Action<AssetLoaderContext> OnMaterialsLoad, Action<AssetLoaderContext, float> OnProgress, Action<IContextualizedError> OnError)
+    static void loadFile(string ModelPath, Action<AssetLoaderContext> OnLoad, Action<AssetLoaderContext> OnMaterialsLoad, Action<AssetLoaderContext, float> OnProgress, Action<IContextualizedError> OnError, GameObject go = null)
     {
         var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();
-        AssetLoader.LoadModelFromFile(ModelPath, OnLoad, OnMaterialsLoad, OnProgress, OnError, null, assetLoaderOptions);
+        AssetLoader.LoadModelFromFile(ModelPath, OnLoad, OnMaterialsLoad, OnProgress, OnError, go, assetLoaderOptions);
     }
     /// <summary>
     /// Called when any error occurs.