84 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			84 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			C#
		
	
	
| 
 | |
| 
 | |
| using System;
 | |
| 
 | |
| namespace Guru.UI
 | |
| {
 | |
|     using UnityEngine;
 | |
|     
 | |
|     public class ViewBase: MonoBehaviour, IView, IDisposable
 | |
|     {
 | |
| 
 | |
|         private Transform _transform;
 | |
|         public Transform Transform
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 if (_transform == null) _transform = gameObject.transform;
 | |
|                 return _transform;
 | |
|             }
 | |
|         }
 | |
|         
 | |
|         private RectTransform _rectTransform;
 | |
|         public RectTransform RectTransform
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 if (_rectTransform == null) _rectTransform = gameObject.GetComponent<RectTransform>();
 | |
|                 return _rectTransform;
 | |
|             }
 | |
|         }
 | |
|         
 | |
| 
 | |
|         public string Name
 | |
|         {
 | |
|             get => gameObject.name;
 | |
|             set => gameObject.name = value;
 | |
|         }
 | |
|         
 | |
|         public Vector3 LocalPosition
 | |
|         {
 | |
|             get => Transform.localPosition;
 | |
|             set => Transform.localPosition = value;
 | |
|         }
 | |
| 
 | |
|         public Vector3 Position
 | |
|         {
 | |
|             get => Transform.position;
 | |
|             set => Transform.position = value;
 | |
|         }
 | |
| 
 | |
|         public Vector2 AnchoredPos
 | |
|         {
 | |
|             get => RectTransform.anchoredPosition;
 | |
|             set => RectTransform.anchoredPosition = value;
 | |
|         } 
 | |
|         
 | |
|         public float Scale
 | |
|         {
 | |
|             get => _transform.localScale.x;
 | |
|             set => _transform.localScale = Vector3.one * value;
 | |
|         }
 | |
| 
 | |
|         public bool Active
 | |
|         {
 | |
|             get => gameObject.activeSelf;
 | |
|             set => gameObject.SetActive(value);
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
|         public Transform FindChild(string path) => Transform.Find(path);
 | |
| 
 | |
| 
 | |
|         public virtual void Refresh()
 | |
|         {
 | |
|             
 | |
|         }
 | |
| 
 | |
|         public virtual void Dispose()
 | |
|         {
 | |
|             
 | |
|         }
 | |
|     }
 | |
| } |