You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Resize with MenuSizeChangerCoroutine() coroutine, using Animation Curve Editor
// create UI Panel in Unity Editor with size 2200, 1100, call it "menuInventoryPanel".
// creat script for this UI Panel called "inventoryMenuScript" and copy this code there.
// in Inspector for UI Panel change "Animation Curve" AnimationCurve to 5ft from left, which looks like letter "S", this cuurve called logistic curve.
// create Button in Unity Editor, in "On Click()" editor add new element and atache "menuInventoryPanel" and choose "inventoryMenuScript > InventoryInteraction0" as function.
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class inventoryMenuScript : MonoBehaviour
{
public AnimationCurve animationCurve;
public Vector2 desiredMenuSize;
public float lerpTimer = 0f;
public bool inventoryMenuSizeChanger = false;
void Start()
{
this.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f);
this.GetComponent<RectTransform>().anchorMin = new Vector2(0.5f, 0.5f);
this.GetComponent<RectTransform>().anchorMax = new Vector2(0.5f, 0.5f);
this.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 0f);
this.GetComponent<RectTransform>().sizeDelta = new Vector2(1760f, 880f);
}
public void InventoryInteraction()
{
lerpTimer = 0; // reset lerpTimer which is referenced as 3rd variable of Lerp
MenuSizeVariable(); // if clicked then change desired deltaSize variable
IEnumerator MenuSizeChangerCoroutine(Vector2 sizeCurrent, Vector2 sizeNew) // coroutine to change size of the element with Vector2.Lerpd using animationCurve as 3rd variable