| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | |
| | | namespace Snxxz.UI |
| | | [ExecuteInEditMode] |
| | | [RequireComponent(typeof(RectTransform))] |
| | | public class UIPrefabLoader : MonoBehaviour |
| | | { |
| | | [SerializeField] string m_PrefabName; |
| | | public string prefabName { get { return m_PrefabName; } } |
| | | |
| | | GameObject instance; |
| | | |
| | | [ExecuteInEditMode] |
| | | [RequireComponent(typeof(RectTransform))] |
| | | public class UIPrefabLoader : MonoBehaviour |
| | | private void Awake() |
| | | { |
| | | [SerializeField] string m_PrefabName; |
| | | public string prefabName { get { return m_PrefabName; } } |
| | | Create(); |
| | | } |
| | | |
| | | GameObject instance; |
| | | |
| | | [ExecuteInEditMode] |
| | | private void Awake() |
| | | [ContextMenu("Create")] |
| | | public void Create() |
| | | { |
| | | if (instance != null) |
| | | { |
| | | Create(); |
| | | return; |
| | | } |
| | | |
| | | [ContextMenu("Create")] |
| | | public void Create() |
| | | if (string.IsNullOrEmpty(m_PrefabName)) |
| | | { |
| | | if (instance != null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(m_PrefabName)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var find = this.transform.Find(m_PrefabName); |
| | | if (find) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | instance = UIUtility.CreateWidget(m_PrefabName, m_PrefabName); |
| | | instance.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | return; |
| | | } |
| | | |
| | | var find = this.transform.Find(m_PrefabName); |
| | | if (find) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | instance = UIUtility.CreateWidget(m_PrefabName, m_PrefabName); |
| | | instance.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |