App Development with Unity Part 18: C# and URLs - How to Get to the Outside World!
ฝัง
- เผยแพร่เมื่อ 27 ก.ค. 2024
- We just keep leveling up! Now that we have our app working better, let's add a way to direct the user to outside webpages. Why create the content in app if a website already provides it?
With one line of code we can add some cool, reusable functionality. Follow along and let's get to it!
Thank you for your video!
Please, how can use the Application.openURL with this code. I tried many times with many modifications, the video clips open, but the URLs do not .
using System;
using System.Collections;
using System.Collections.Generic;
using GoogleARCore;
using UnityEngine;
using UnityEngine.Video;
public class AugmentedImageVisualizer : MonoBehaviour
{
[SerializeField]
private List videosClips;
public AugmentedImage Image;
private VideoPlayer _videoPlayer;
[Serializable]
public struct VideoLocation
{
public string url;
public VideoClip videoClip;
public void Url()
{
Application.OpenURL(url);
}
public static implicit operator VideoClip(VideoLocation v)
{
return v.videoClip;
}
}
void Start()
{
_videoPlayer = GetComponent();
_videoPlayer.loopPointReached += OnStop;
}
private void OnStop(VideoPlayer source)
{
gameObject.SetActive(false);
}
void Update()
{
if (Image == null || Image.TrackingState != TrackingState.Tracking)
{
return;
}
if (!_videoPlayer.isPlaying)
{
_videoPlayer.clip = videosClips[Image.DatabaseIndex];
_videoPlayer.Play();
}
transform.localScale = new Vector3(Image.ExtentX, Image.ExtentZ, 1);
}
}
can you make a tutorial how to create webview without leaving the app? Tq
You mean how to use a web-view inside of a unity app at runtime? Sure, I could do that. I'll put that on my list. I've been wanting to get back into making videos again. Stay tuned! :)