2020-05-31 03:10:11 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using TMPro;
|
|
|
|
|
|
using UnityEngine;
|
2020-06-02 07:01:03 +01:00
|
|
|
|
using UnityEngine.EventSystems;
|
2020-05-31 03:10:11 +01:00
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
2020-06-01 03:11:04 +01:00
|
|
|
|
public class PropertiesList : PropertiesPanel
|
2020-05-31 03:10:11 +01:00
|
|
|
|
{
|
|
|
|
|
|
public Image FoldoutIcon;
|
|
|
|
|
|
public float FoldoutRotationDamping;
|
|
|
|
|
|
public FlatFlatButton Button;
|
|
|
|
|
|
public VerticalLayoutGroup LayoutGroup;
|
|
|
|
|
|
public int FoldedPadding = -8;
|
|
|
|
|
|
public int ExpandedPadding = 8;
|
|
|
|
|
|
|
|
|
|
|
|
private bool _expanded = false;
|
|
|
|
|
|
private float _targetFoldoutRotation = 0;
|
|
|
|
|
|
private float _foldoutRotation = 0;
|
|
|
|
|
|
|
|
|
|
|
|
public bool Expanded
|
|
|
|
|
|
{
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
_expanded = value;
|
|
|
|
|
|
var padding = LayoutGroup.padding;
|
|
|
|
|
|
padding = new RectOffset(padding.left, padding.right, padding.top, _expanded ? ExpandedPadding : FoldedPadding);
|
|
|
|
|
|
LayoutGroup.padding = padding;
|
|
|
|
|
|
foreach (var property in Properties) property.SetActive(_expanded);
|
|
|
|
|
|
_targetFoldoutRotation = _expanded ? -90 : 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Start()
|
|
|
|
|
|
{
|
2020-06-02 07:01:03 +01:00
|
|
|
|
Button.OnClick += _ => ToggleExpand();
|
2020-05-31 03:10:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ToggleExpand() => Expanded = !_expanded;
|
|
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
_foldoutRotation =
|
|
|
|
|
|
Mathf.Lerp(_foldoutRotation, _targetFoldoutRotation, FoldoutRotationDamping * Time.deltaTime);
|
|
|
|
|
|
FoldoutIcon.transform.localRotation = Quaternion.Euler(0,0, _foldoutRotation);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-02 07:01:03 +01:00
|
|
|
|
public override PropertyLabel AddProperty(string name, Func<string> read = null, Action<PointerEventData> onClick = null, bool radio = false)
|
2020-05-31 03:10:11 +01:00
|
|
|
|
{
|
2020-06-02 07:01:03 +01:00
|
|
|
|
var prop = base.AddProperty(name, read, onClick, radio);
|
2020-05-31 03:10:11 +01:00
|
|
|
|
prop.gameObject.SetActive(false);
|
|
|
|
|
|
return prop;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-02 07:01:03 +01:00
|
|
|
|
public override PropertiesList AddList(string name)
|
2020-05-31 03:10:11 +01:00
|
|
|
|
{
|
|
|
|
|
|
var list = base.AddList(name);
|
|
|
|
|
|
list.gameObject.SetActive(false);
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-02 07:01:03 +01:00
|
|
|
|
public override RectTransform AddSection(string name)
|
2020-05-31 03:10:11 +01:00
|
|
|
|
{
|
|
|
|
|
|
var section = base.AddSection(name);
|
|
|
|
|
|
section.gameObject.SetActive(false);
|
|
|
|
|
|
return section;
|
|
|
|
|
|
}
|
2020-06-02 07:01:03 +01:00
|
|
|
|
|
|
|
|
|
|
public override PropertyButton AddButton(string name, Action<PointerEventData> onClick)
|
|
|
|
|
|
{
|
|
|
|
|
|
var button = base.AddButton(name, onClick);
|
|
|
|
|
|
button.gameObject.SetActive(false);
|
|
|
|
|
|
return button;
|
|
|
|
|
|
}
|
2020-05-31 03:10:11 +01:00
|
|
|
|
}
|