1#pragma warning disable 649
19 [SerializeField]
private RectTransform _loadingBar;
24 [SerializeField]
private GameObject _helpWrapper;
29 [SerializeField]
private GameObject _loadingWrapper;
34 [SerializeField]
private GameObject _modelUrlDialog;
39 [SerializeField]
private InputField _modelUrl;
59 [SerializeField]
protected Selectable
Play;
64 [SerializeField]
protected Selectable
Stop;
104 _helpWrapper.SetActive(
true);
112 _helpWrapper.SetActive(
false);
120 _modelUrlDialog.SetActive(
true);
122 _modelUrl.ActivateInputField();
130 _modelUrlDialog.SetActive(
false);
131 _modelUrl.text =
null;
138 Action<AssetLoaderContext> onMaterialsLoad =
null)
149 GameObject wrapperGameObject =
null,
object customData =
null,
150 Action<AssetLoaderContext> onMaterialsLoad =
null)
155 fileExtension = fileExtension.ToLowerInvariant();
156 var isZipFile = fileExtension ==
"zip" || fileExtension ==
".zip";
158 wrapperGameObject,
AssetLoaderOptions, customData, isZipFile ?
null : fileExtension, isZipFile);
166 if (
string.IsNullOrWhiteSpace(_modelUrl.text))
return;
169 FileUtils.GetFileExtension(request.uri.Segments[request.uri.Segments.Length - 1],
false);
190 var selectables = FindObjectsOfType<Selectable>();
191 for (var i = 0; i < selectables.Length; i++)
193 var button = selectables[i];
194 button.interactable = !value;
196#if UNITY_WSA || UNITY_WEBGL || TRILIB_FORCE_SYNC
197 _loadingWrapper.gameObject.SetActive(value);
199 _loadingBar.gameObject.SetActive(value);
206 Dispatcher.CheckInstance();
217 protected virtual void OnProgress(AssetLoaderContext assetLoaderContext,
float value)
219 _loadingBar.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Screen.width * value);
224 protected virtual void OnError(IContextualizedError contextualizedError)
226 Debug.LogError(contextualizedError);
236 protected virtual void OnLoad(AssetLoaderContext assetLoaderContext)
TriLibCore.AssetLoaderOptions AssetLoaderOptions
Represents a class to download and load Models.
static Coroutine LoadModelFromUri(UnityWebRequest unityWebRequest, Action< AssetLoaderContext > onLoad, Action< AssetLoaderContext > onMaterialsLoad, Action< AssetLoaderContext, float > onProgress, Action< IContextualizedError > onError=null, GameObject wrapperGameObject=null, AssetLoaderOptions assetLoaderOptions=null, object customContextData=null, string fileExtension=null, bool? isZipFile=null)
Loads a Model from the given URI Asynchronously (Accepts zip files).
static UnityWebRequest CreateWebRequest(string uri, HttpRequestMethod httpRequestMethod=HttpRequestMethod.Get, string data=null, int timeout=2000)
Creates a Unity Web Request from the given parameters.
Represents an Asset Loader which loads files using a platform-specific file picker.
static AssetLoaderFilePicker Create()
Creates the Asset Loader File Picker Singleton instance.
void LoadModelFromFilePickerAsync(string title, Action< AssetLoaderContext > onLoad, Action< AssetLoaderContext > onMaterialsLoad, Action< AssetLoaderContext, float > onProgress, Action< bool > onBeginLoad, Action< IContextualizedError > onError, GameObject wrapperGameObject, AssetLoaderOptions assetLoaderOptions)
Loads a Model from the OS file picker asynchronously, or synchronously when the OS doesn't support Th...
Represents a base class used in TriLib samples.
Text PlaybackTime
Animation playback time.
Selectable Play
Play button.
Vector2 CameraAngle
Current camera pitch and yaw angles.
void ShowModelUrlDialog()
Shows the model URL dialog.
Dropdown PlaybackAnimation
Animation selector.
virtual void StopAnimation()
Stops playing the selected animation.
void HideHelp()
Hides the help box.
void HideModelUrlDialog()
Hides the model URL dialog.
virtual void OnLoad(AssetLoaderContext assetLoaderContext)
Event is triggered when the Model Meshes and hierarchy are loaded.
void SetLoading(bool value)
Enables/disables the loading flag.
void LoadModelFromURL(UnityWebRequest request, string fileExtension, GameObject wrapperGameObject=null, object customData=null, Action< AssetLoaderContext > onMaterialsLoad=null)
Loads a model from a URL.
GameObject RootGameObject
Loaded game object.
virtual void PlayAnimation()
Plays the selected animation.
virtual void OnProgress(AssetLoaderContext assetLoaderContext, float value)
Event is triggered when the Model loading progress changes.
Slider PlaybackSlider
Animation playback slider.
void LoadModelFromFile(GameObject wrapperGameObject=null, Action< AssetLoaderContext > onMaterialsLoad=null)
Shows the file picker for loading a model from local file-system.
Selectable Stop
Stop button.
static AssetViewerBase Instance
Gets the Asset Viewer Singleton instance.
const float InputMultiplierRatio
Mouse input multiplier. Higher values will make the mouse movement more sensible.
virtual void PlaybackSliderChanged(float value)
Event triggered when the animation slider value has been changed by the user.
void LoadModelFromURLWithDialogValues()
Shows the URL selector for loading a model from network.
virtual void OnBeginLoadModel(bool hasFiles)
Event triggered when the user selects a file or cancels the Model selection dialog.
virtual void Start()
Checks if the Dispatcher instance exists and stores this class instance as the Singleton.
void ShowHelp()
Shows the help box.
AssetLoaderOptions AssetLoaderOptions
Options used in this sample.
virtual void OnMaterialsLoad(AssetLoaderContext assetLoaderContext)
Event is triggered when the Model (including Textures and Materials) has been fully loaded.
void UpdateCamera()
Updates the Camera based on mouse Input.
virtual void PlaybackAnimationChanged(int index)
Switches to the animation selected on the Dropdown.
const float MaxPitch
Maximum camera pitch and light pitch (rotation around local X-axis).
virtual void OnError(IContextualizedError contextualizedError)
Event is triggered when any error occurs.
Represents a Class used to add paste capabilities to WebGL projects.
static void CheckInstance()
Checks if the Singleton instance exists.