private void CheckQuerystringParameters() { var avatarQuerystring = ""; #if UNITY_WEBGL && !UNITY_EDITOR avatarQuerystring = WebpageUtilities.GetURLParameters(); #elif TEST_LOAD_ON_START avatarQuerystring = "avtr_53411a6e-8b3a-486e-983a-9249d7b6a087"; #endif if (!string.IsNullOrEmpty(avatarQuerystring)) { LoadAvatar(avatarQuerystring); } }
//this doesnt seem to work? private IEnumerator UpdateInpasdasdfutFromQueryString() { yield return(null); #if UNITY_WEBGL && !UNITY_EDITOR if (!Application.isEditor) { yield return(new WaitForSeconds(1f)); var queryString = WebpageUtilities.GetURLParameters(); if (!string.IsNullOrEmpty(queryString)) { AvatarIdInput.text = queryString; } } #endif }
void Start() { AvatarNameMainText = GameObject.Find("AvatarNameMainText").GetComponent <Text>(); AvatarNameSubtitleText = GameObject.Find("AvatarNameSubtitleText").GetComponent <Text>(); StatusText = GameObject.Find("StatusText").GetComponent <Text>(); InformationText = GameObject.Find("InformationText").GetComponent <Text>(); BottomPanel = GameObject.Find("BottomPanel"); BottomPanel.SetActive(false); //top panel AvatarIdInput = GameObject.Find("AvatarIdInput").GetComponent <InputField>(); AvatarIdInput.onValueChanged.AddListener((newValue) => { Regex r = new Regex("^[a-zA-Z\\d-_]+$"); if (r.IsMatch(newValue)) { WebpageUtilities.SetURLParameters(newValue, true); } else { Debug.Log("not regex match"); } }); GetAvatarButton = GameObject.Find("GetAvatarButton").GetComponent <Button>(); GetAvatarButton.onClick.AddListener(() => { AvatarLoader.instance.LoadAvatar(AvatarIdInput.text); }); /* * CopyFromAddressbarButton = GameObject.Find("CopyFromAddressbarButton").GetComponent<Button>(); * CopyFromAddressbarButton.onClick.AddListener(() => * { * var queryString = WebpageUtilities.GetURLParameters(); * if (!string.IsNullOrEmpty(queryString)) * { * AvatarIdInput.text = queryString; * } * }); */ //settings SettingsPanel = GameObject.Find("SettingsPanel"); SettingsToggleButton = GameObject.Find("SettingsToggleButton").GetComponent <Button>(); SettingsToggleButton.onClick.AddListener(() => { SettingsPanel.SetActive(!SettingsPanel.activeSelf); }); SkyboxDropdown = GameObject.Find("SkyboxDropdown").GetComponent <Dropdown>(); SkyboxDropdown.options = GetSkyboxDropdownOptions(); SkyboxDropdown.onValueChanged.AddListener((value) => { SettingsManager.instance.SetSkybox(value); }); LightIntensitySlider = GameObject.Find("LightIntensitySlider").GetComponent <Slider>(); LightIntensitySlider.maxValue = SettingsManager.LIGHT_INTENSITY_MAX; LightIntensitySlider.minValue = SettingsManager.LIGHT_INTENSITY_MIN; LightIntensitySlider.value = SettingsManager.instance.GetLightIntensity(); LightIntensitySlider.onValueChanged.AddListener((value) => { SettingsManager.instance.SetLightIntensity(value); }); AmbientIntensitySlider = GameObject.Find("AmbientIntensitySlider").GetComponent <Slider>(); AmbientIntensitySlider.maxValue = SettingsManager.LIGHT_INTENSITY_MAX; AmbientIntensitySlider.minValue = SettingsManager.LIGHT_INTENSITY_MIN; AmbientIntensitySlider.value = SettingsManager.instance.GetAmbientIntensity(); AmbientIntensitySlider.onValueChanged.AddListener((value) => { SettingsManager.instance.SetAmbientIntensity(value); }); ReplacementShaderDropdown = GameObject.Find("ReplacementShaderDropdown").GetComponent <Dropdown>(); ReplacementShaderDropdown.options = GetReplacmentShadersDropdownOptions(); ReplacementShaderDropdown.onValueChanged.AddListener((value) => { SettingsManager.instance.SetReplacmentShader(value); }); SettingsPanel.SetActive(false); mainLoadingBar.gameObject.SetActive(false); //StartCoroutine(UpdateInputFromQueryString()); }
public void LoadAvatar(string avatarID, string worldId = "") { //todo: Disable ui? //todo: cancel button try { UIManager.instance.SetMainTitle("Loading avatar", "Getting avatar info..."); StartCoroutine(VRCAPIHandler.GetAvatarInfo(avatarID, (avatarInfo) => { if (avatarInfo.releaseStatus != "public") { UIManager.instance.SetMainTitle(null, "This avatar is not public and cannot be viewed."); return; } UIManager.instance.SetMainTitle(avatarInfo.name, "By: " + avatarInfo.authorName); StartCoroutine(DownloadAvatar(VRCAPIHandler.CheckProxyUrl(avatarInfo.assetUrl), () => { StartCoroutine(InstantiateAvatar(() => { StartCoroutine(GetInformation(avatarInfo, instantiatedAvatar)); UIManager.instance.SetMainTitle(avatarInfo.name, "By: " + avatarInfo.authorName); UIManager.instance.SetLoadedAvatarId(avatarInfo.id); GameObject mouseOrbitFollow = new GameObject("MouseOrbitFollow"); //mouseOrbitFollow.transform.position = instantiatedAvatar.GetComponentInChildren<Renderer>().bounds.center; var boundsCenter = instantiatedAvatar.GetComponentInChildren <Renderer>().bounds.center; mouseOrbitFollow.transform.position = new Vector3(0f, boundsCenter.y, 0f); mouseOrbit.target = mouseOrbitFollow.transform; if (avatarInfo.name == null) { avatarInfo.name = ""; } if (avatarInfo.authorName == null) { avatarInfo.authorName = "?"; } StartCoroutine(ResetAvatarPosition()); WebpageUtilities.SetURLParameters(avatarInfo.id); if (!string.IsNullOrEmpty(worldId)) { Debug.Log("Getting world info..."); StartCoroutine(VRCAPIHandler.GetWorldInfo(worldId, (info) => { Debug.Log("From world " + info.name); //avatarInfo.authorName += "\r\n" + "From world: " + info.name; UIManager.instance.SetMainTitle(avatarInfo.name, "By: " + avatarInfo.authorName + "\r\n" + "From world: " + info.name); })); } //todo: enable UI })); })); }, (error) => { UIManager.instance.SetMainTitle(null, "Error"); })); } catch (Exception e) { Debug.Log(e.ToString()); } }