public void SameHeightSwitch() { if (proportionMode == 2) { return; } proportionMode = 2; if (imageList.Count == 0) { return; } getIndex(); RawImage ri = imageList[index].GetComponent <RawImage>(); float baseHeight = imageList[index].transform.localScale.x * ri.texture.height; for (int i = 0; i < imageList.Count; i++) { UniGifImage gifScript = imageList[i].GetComponent <UniGifImage>(); if (gifScript != null) { gifScript.Play(); } ri = imageList[i].GetComponent <RawImage>(); // Rescales images so they all have the same height as baseHeight float newScale = baseHeight / ri.texture.height; if (gifScript != null) { gifScript.Stop(); } imageList[i].transform.localScale = newScale * Vector3.one; } RecalculateArrangement(); }
public void Create(string url) { gameObject.transform.position = new Vector3(0f, 0f, 0f); gameObject.transform.eulerAngles = new Vector3(0f, 0f, 0f); gameObject.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f); _imageCanvas = gameObject.AddComponent <Canvas>(); _imageCanvas.renderMode = RenderMode.WorldSpace; _panelLeftG = new GameObject("GIFPanelImageLeft").AddComponent <RawImage>(); _panelLeftG.material = Utilities.Sprites.NoGlowMat; _panelLeftG.rectTransform.SetParent(_imageCanvas.transform, false); _panelLeftG.rectTransform.anchorMin = new Vector2(0.5f, 0.5f); _panelLeftG.rectTransform.anchorMax = new Vector2(0.5f, 0.5f); _panelLeftG.rectTransform.anchoredPosition = new Vector2(4.5f, 4.5f); _panelLeftG.rectTransform.sizeDelta = new Vector2(7f, 7f); gifimage = _panelLeftG.gameObject.AddComponent <UniGifImage>(); UniGifImageAspectController ugiac = _panelLeftG.gameObject.AddComponent <UniGifImageAspectController>(); gifimage.SetPrivateField("m_imgAspectCtrl", ugiac); _panelLeftG.color = new Color(1, 1, 1, .6f); _panelLeftG.enabled = false; StartCoroutine(SetGIF(url)); }
public void LoadAssets() { float actualHeight = padding * -1; // Remove all child from previous display foreach (Transform child in container.transform) { GameObject.Destroy(child.gameObject); } // Create all elements for (int i = 0; i < data.Length; i++) { Media media = data [i].media [0].mediumgif; var ratio = elementWidth / media.dims [0]; // Instatiate New Game Object GameObject tenorGO = Instantiate(GameObject.Find("GIFContainer"), container.transform); // Look for the GIF asset UniGifImage imageGIF = tenorGO.GetComponent <UniGifImage> (); StartCoroutine(imageGIF.SetGifFromUrlCoroutine(media.url)); // Update Scroll position tenorGO.transform.localPosition = new Vector3(padding, actualHeight, 0); actualHeight -= (media.dims [1] * ratio) + padding; } // Adjust Container Height RectTransform rt = container.GetComponent(typeof(RectTransform)) as RectTransform; rt.sizeDelta = new Vector2(elementWidth + 2 * padding, actualHeight * -1); }
public void PostGif(string url) { GameObject tmp = Instantiate(gifMemePrefab); tmp.GetComponent <RectTransform>().anchoredPosition = StartPositions[Random.Range(0, StartPositions.Count - 1)].position; UniGifImage m_uniGifImage = tmp.GetComponent <UniGifImage>(); StartCoroutine(m_uniGifImage.SetGifFromUrlCoroutine(url)); }
protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { base.DidActivate(firstActivation, addedToHierarchy, screenSystemEnabling); if (firstActivation && PluginConfig.Instance.EnablePlugin && PluginConfig.Instance.ShowGIFs) { UniGif = rawImageGif.gameObject.AddComponent <UniGifImage>(); var ugiac = UniGif.gameObject.AddComponent <UniGifImageAspectController>(); UniGif.SetPrivateField("m_imgAspectCtrl", ugiac); } }
protected override void DidActivate(bool firstActivation, ActivationType type) { base.DidActivate(firstActivation, type); if (firstActivation && Plugin.config.Value.EnablePlugin && Plugin.config.Value.ShowGIFs) { UniGif = rawImageGif.gameObject.AddComponent <UniGifImage>(); var ugiac = UniGif.gameObject.AddComponent <UniGifImageAspectController>(); UniGif.SetPrivateField("m_imgAspectCtrl", ugiac); } }
private void _SetupDrinkWaterPanel() { if (_CustomMenu != null && _CustomViewController != null) { return; } _CustomMenu = BeatSaberUI.CreateCustomMenu <CustomMenu>("Drink some cum!"); _CustomViewController = BeatSaberUI.CreateViewController <CustomViewController>(); _CustomViewController.name = "DrinkCumPanel"; if (_CustomMenu != null && _CustomViewController != null) { _CustomMenu.SetMainViewController(_CustomViewController, false, (firstActivation, type) => { if (firstActivation && type == VRUI.VRUIViewController.ActivationType.AddedToHierarchy) { _TextContent = _CustomViewController.CreateText("", new Vector2(0, 28f)); _TextContent.alignment = TextAlignmentOptions.Center; _TextContent.fontSize = 5; _TextContent.enableWordWrapping = false; _ContinueButton = _CustomViewController.CreateUIButton("CreditsButton", new Vector2(0, -28f), new Vector2(37f, 10f), null, "I understand!"); _ContinueButton.ToggleWordWrapping(false); _ContinueButton.SetButtonTextSize(4); _ContinueButton.onClick.AddListener(delegate() { _CustomMenu.Dismiss(); Destroy(_CustomViewController.gameObject, 1); _CustomMenu = null; _CustomViewController = null; }); _RefreshTextContent(_CurrentPanelMode); if (PluginConfig.ShowGIFs) { GameObject go = new GameObject("[BeatSaberDrinkCum] PreviewGif"); _RawImage = go.AddComponent <RawImage>(); _RawImage.material = Instantiate(Resources.FindObjectsOfTypeAll <Material>().Where(m => m.name == "UINoGlow").FirstOrDefault()); go.transform.SetParent(_CustomViewController.transform, false); go.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0); go.GetComponent <RectTransform>().sizeDelta = new Vector2(30, 30); _UniGifImage = go.AddComponent <UniGifImage>(); UniGifImageAspectController ugiac = go.AddComponent <UniGifImageAspectController>(); _UniGifImage.SetPrivateField("m_imgAspectCtrl", ugiac); StartCoroutine(_DisplayGifFromRotation()); } } }); } else { Console.WriteLine("[BeatSaberCustomExit.MainMenuUIOverload]: '_CustomMenu' or '_CustomViewController' was null."); } }
/* * public void ReloadImage() * { * // Needs special check for whether image is a .gif * print("Index: " + index); // 0 remains out of range * //while (textureLists.Count <= index) * // print("Waiting for load..."); // this approach causes Unity to freeze * img.texture = textureLists[index]; * Vector2 sDelta = 0.02f * Mathf.Pow(scaleFactor, 2) * (new Vector2(img.texture.width, img.texture.height)); * img.rectTransform.sizeDelta = sDelta; * imgCollider.size = new Vector3(sDelta.x, sDelta.y, .01f); * } */ public void DisableImage(int imageIndex) { GameObject curImgObj = imageList[imageIndex]; UniGifImage gifScript = curImgObj.GetComponent <UniGifImage>(); if (gifScript != null) { print("StoppingGif"); gifScript.Stop(); } RawImage curImg = curImgObj.GetComponent <RawImage>(); BoxCollider curColl = curImgObj.GetComponent <BoxCollider>(); curColl.enabled = false; curImg.enabled = false; }
public void EnableImage(int imageIndex) { GameObject curImgObj = imageList[imageIndex]; UniGifImage gifScript = curImgObj.GetComponent <UniGifImage>(); if (gifScript != null) { print("PlayingGif"); gifScript.Play(); } RawImage curImg = curImgObj.GetComponent <RawImage>(); BoxCollider curColl = curImgObj.GetComponent <BoxCollider>(); //Vector2 sDelta = 0.02f * Mathf.Pow(scaleFactor, 2) * (new Vector2(curImg.texture.width, curImg.texture.height)); Vector2 sDelta = new Vector2(curImg.texture.width, curImg.texture.height); curImg.rectTransform.sizeDelta = sDelta; curColl.size = new Vector3(sDelta.x, sDelta.y, .01f); curColl.enabled = true; curImg.enabled = true; }
// Start is called before the first frame update void Start() { GifImage = RawImage.GetComponent <UniGifImage>(); HeartEffect = GameObject.Find("HeartEffectGenerator").GetComponent <HeartEffectGen>(); }
// Use this for initialization void Start() { render = transform.gameObject.GetComponent <Renderer>(); unigif = transform.gameObject.GetComponent <UniGifImage>(); }
private void Update() { switch (nowState) { case State.None: break; case State.Loading: if (m_rotateOnLoading) { transform.Rotate(0f, 0f, 30f * Time.deltaTime, Space.Self); } break; case State.Ready: break; case State.Playing: if (m_rawImage == null || m_gifTextureList == null || m_gifTextureList.Count <= 0) { return; } if (m_delayTime > Time.time) { return; } // Change texture m_gifTextureIndex++; if (m_gifTextureIndex >= m_gifTextureList.Count) { UniGifImage onePicture = GameObject.Find("RawImage").GetComponent <UniGifImage>(); if (onePicture.m_loadOnStartUrl == "sister.gif") { loopCount = 2; } else { loopCount = 5; } m_gifTextureIndex = 0; if (loopCount > 0) { m_nowLoopCount++; if (m_nowLoopCount >= loopCount) { // ハートの数が一定数超えない場合returnする HeartEffectGen heart = GameObject.Find("HeartEffectGenerator").GetComponent <HeartEffectGen>(); heart.SetHeartCount(0); // GifCtlをもらう GifCtl gifCtl = GameObject.Find("GifControl").GetComponent <GifCtl>(); gifCtl.SetGifPlaying(false); loopCount = 0; Stop(); return; } } } m_rawImage.texture = m_gifTextureList[m_gifTextureIndex].m_texture2d; m_delayTime = Time.time + m_gifTextureList[m_gifTextureIndex].m_delaySec; break; case State.Pause: break; default: break; } }
void Start() { uniGifImage = GetComponent <UniGifImage>(); }