Universal Properties Panel
Properties panel is now shared between tabs
This commit is contained in:
parent
4f29bf24d0
commit
87acc75b96
25 changed files with 11397 additions and 41840 deletions
10
Assets/Scripts/UI/PropertyLabel.cs
Normal file
10
Assets/Scripts/UI/PropertyLabel.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class PropertyLabel : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI Name;
|
||||
public TextMeshProUGUI Value;
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e422bcc206d214044ab697caaac9fd12
|
||||
guid: b403db1d8980f544099fedf5735cf364
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
65
Assets/Scripts/UI/ReadOnlyPropertiesPanel.cs
Normal file
65
Assets/Scripts/UI/ReadOnlyPropertiesPanel.cs
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class ReadOnlyPropertiesPanel : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI Title;
|
||||
public RectTransform SectionPrefab;
|
||||
public RectTransform ListPrefab;
|
||||
public RectTransform ListItemPrefab;
|
||||
public PropertyLabel ListPropertyPrefab;
|
||||
public PropertyLabel PropertyPrefab;
|
||||
|
||||
private List<GameObject> _properties = new List<GameObject>();
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
foreach(var property in _properties)
|
||||
Destroy(property);
|
||||
}
|
||||
|
||||
public void AddProperty(string name, string value)
|
||||
{
|
||||
var property = Instantiate(PropertyPrefab, transform);
|
||||
property.Name.text = name;
|
||||
property.Value.text = value;
|
||||
_properties.Add(property.gameObject);
|
||||
}
|
||||
|
||||
public void AddSection(string name)
|
||||
{
|
||||
var section = Instantiate(SectionPrefab, transform);
|
||||
section.GetComponentInChildren<TextMeshProUGUI>().text = name;
|
||||
_properties.Add(section.gameObject);
|
||||
}
|
||||
|
||||
public void AddList(string name, IEnumerable<string> elements)
|
||||
{
|
||||
var list = Instantiate(ListPrefab, transform);
|
||||
list.GetComponentInChildren<TextMeshProUGUI>().text = name;
|
||||
foreach (var element in elements)
|
||||
{
|
||||
var item = Instantiate(ListItemPrefab, list);
|
||||
item.GetComponentInChildren<TextMeshProUGUI>().text = element;
|
||||
_properties.Add(item.gameObject);
|
||||
}
|
||||
_properties.Add(list.gameObject);
|
||||
}
|
||||
|
||||
public void AddList(string name, IEnumerable<Tuple<string, string>> elements)
|
||||
{
|
||||
var list = Instantiate(ListPrefab, transform);
|
||||
list.GetComponentInChildren<TextMeshProUGUI>().text = name;
|
||||
foreach (var element in elements)
|
||||
{
|
||||
var item = Instantiate(ListPropertyPrefab, list);
|
||||
item.Name.text = element.Item1;
|
||||
item.Value.text = element.Item2;
|
||||
_properties.Add(item.gameObject);
|
||||
}
|
||||
_properties.Add(list.gameObject);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/ReadOnlyPropertiesPanel.cs.meta
Normal file
11
Assets/Scripts/UI/ReadOnlyPropertiesPanel.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8c2bf4a7080061d42a87046c37bf0c60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class ZonePropertiesResource : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI NameLabel;
|
||||
public TextMeshProUGUI QuantityLabel;
|
||||
}
|
||||
Loading…
Reference in a new issue