[34321-resources.zip|34321]Why my window dont work on start? (watch video pls)
https://www.dropbox.com/s/k2tuwpfef4t5t9p/UI%20Window.flv?dl=0
[34321-resources.zip|34321]Why my window dont work on start? (watch video pls)
https://www.dropbox.com/s/k2tuwpfef4t5t9p/UI%20Window.flv?dl=0
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class UIWindow : MonoBehaviour {
public RectTransform windowRect; //UI Window - Main rect
public RectTransform dragRect; //UI Window - Drag rect
public RectTransform titleRect; //UI Window - Title rect
public RectTransform btnCloseRect; //UI Window - Close Button rect
public RectTransform contentHolderRect; //UI Window - Content Holder rect
public RectTransform contentRect; //UI Window - Content rect
public string title;
[Range(0, 10)] public int padding; //UI Window - Padding
[Range(300, 2000)] public int width, height; //UI Window - Width and Height
[Range(20, 100)] public int widthBtnClose, heightBtnClose; //Button Close - Width and Height
void Awake() {
ResetWindow();
}
public void ResetWindow() {
titleRect.GetComponent<Text>().text = title;
windowRect.anchoredPosition = new Vector2(padding, -padding);
windowRect.sizeDelta = new Vector2(width, height);
titleRect.anchoredPosition = new Vector2(padding, -padding);
titleRect.sizeDelta = new Vector2(width - (widthBtnClose + 2 * padding), heightBtnClose);
dragRect.anchoredPosition = new Vector2(0, 0);
dragRect.sizeDelta = new Vector2(width, heightBtnClose + 2 * padding);
btnCloseRect.anchoredPosition = new Vector2(-padding, -padding);
btnCloseRect.sizeDelta = new Vector2(widthBtnClose, heightBtnClose);
contentRect.anchoredPosition = new Vector2(0, -(heightBtnClose + 2 * padding));
contentRect.sizeDelta = new Vector2(width, height - (heightBtnClose + 2 * padding));
}
public void ShowWindow() {
this.gameObject.SetActive(true);
}
public void CloseWindow() {
this.gameObject.SetActive(false);
}
public void DestroyWindow() {
Destroy(this.gameObject);
}
}