mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 03:35:10 +00:00
Dropdown Fixes + TryGetMinigame (#781)
* fix dropdowns + dropdown collapses man... * trygetminigame it's from a different branch but it's nice to have rn
This commit is contained in:
parent
4f776f312a
commit
d42291d57e
3 changed files with 45 additions and 25 deletions
|
@ -414,9 +414,9 @@ RectTransform:
|
||||||
m_Father: {fileID: 574002313}
|
m_Father: {fileID: 574002313}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: -21}
|
||||||
m_SizeDelta: {x: 32, y: 32}
|
m_SizeDelta: {x: 32, y: 32}
|
||||||
m_Pivot: {x: 0, y: 0.5}
|
m_Pivot: {x: 0, y: 0.5}
|
||||||
--- !u!114 &9435782
|
--- !u!114 &9435782
|
||||||
|
@ -3846,9 +3846,9 @@ RectTransform:
|
||||||
m_Father: {fileID: 539838476}
|
m_Father: {fileID: 539838476}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 32, y: -21}
|
||||||
m_SizeDelta: {x: 32, y: 32}
|
m_SizeDelta: {x: 32, y: 32}
|
||||||
m_Pivot: {x: 1, y: 0.5}
|
m_Pivot: {x: 1, y: 0.5}
|
||||||
--- !u!114 &121871281
|
--- !u!114 &121871281
|
||||||
|
@ -4070,9 +4070,9 @@ RectTransform:
|
||||||
m_Father: {fileID: 539838476}
|
m_Father: {fileID: 539838476}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 72, y: -21}
|
||||||
m_SizeDelta: {x: 32, y: 32}
|
m_SizeDelta: {x: 32, y: 32}
|
||||||
m_Pivot: {x: 1, y: 0.5}
|
m_Pivot: {x: 1, y: 0.5}
|
||||||
--- !u!114 &129013734
|
--- !u!114 &129013734
|
||||||
|
@ -4206,9 +4206,9 @@ RectTransform:
|
||||||
m_Father: {fileID: 539838476}
|
m_Father: {fileID: 539838476}
|
||||||
m_RootOrder: 2
|
m_RootOrder: 2
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 112, y: -21}
|
||||||
m_SizeDelta: {x: 32, y: 32}
|
m_SizeDelta: {x: 32, y: 32}
|
||||||
m_Pivot: {x: 1, y: 0.5}
|
m_Pivot: {x: 1, y: 0.5}
|
||||||
--- !u!114 &151246938
|
--- !u!114 &151246938
|
||||||
|
@ -21329,7 +21329,7 @@ RectTransform:
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 1}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 1}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 29.3, y: -29.3}
|
m_AnchoredPosition: {x: 29.300003, y: -29.3}
|
||||||
m_SizeDelta: {x: 48.6, y: 48.6}
|
m_SizeDelta: {x: 48.6, y: 48.6}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &781200687
|
--- !u!114 &781200687
|
||||||
|
@ -32090,7 +32090,7 @@ RectTransform:
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 1, y: 1}
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: -8}
|
m_AnchoredPosition: {x: 0, y: -8.0000305}
|
||||||
m_SizeDelta: {x: 0, y: -63.99999}
|
m_SizeDelta: {x: 0, y: -63.99999}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &1244621693
|
--- !u!114 &1244621693
|
||||||
|
@ -34621,9 +34621,9 @@ RectTransform:
|
||||||
m_Father: {fileID: 574002313}
|
m_Father: {fileID: 574002313}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 40, y: -21}
|
||||||
m_SizeDelta: {x: 32, y: 32}
|
m_SizeDelta: {x: 32, y: 32}
|
||||||
m_Pivot: {x: 0, y: 0.5}
|
m_Pivot: {x: 0, y: 0.5}
|
||||||
--- !u!114 &1345846031
|
--- !u!114 &1345846031
|
||||||
|
@ -42945,9 +42945,9 @@ RectTransform:
|
||||||
m_Father: {fileID: 574002313}
|
m_Father: {fileID: 574002313}
|
||||||
m_RootOrder: 2
|
m_RootOrder: 2
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 80, y: -21}
|
||||||
m_SizeDelta: {x: 32, y: 32}
|
m_SizeDelta: {x: 32, y: 32}
|
||||||
m_Pivot: {x: 0, y: 0.5}
|
m_Pivot: {x: 0, y: 0.5}
|
||||||
--- !u!114 &1783491359
|
--- !u!114 &1783491359
|
||||||
|
|
|
@ -1243,6 +1243,17 @@ namespace HeavenStudio
|
||||||
return eventCaller.GetMinigame(name);
|
return eventCaller.GetMinigame(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool TryGetMinigame<T>(out T mg) where T : Minigame
|
||||||
|
{
|
||||||
|
if (minigame is T tempMinigame) {
|
||||||
|
mg = tempMinigame;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
mg = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Color colMain;
|
Color colMain;
|
||||||
public void SetCurrentGame(string game, bool useMinigameColor = true)
|
public void SetCurrentGame(string game, bool useMinigameColor = true)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace HeavenStudio.Editor
|
||||||
public LeftClickTMP_Dropdown dropdown;
|
public LeftClickTMP_Dropdown dropdown;
|
||||||
public Scrollbar scrollbar;
|
public Scrollbar scrollbar;
|
||||||
|
|
||||||
|
public int[] values;
|
||||||
private int _defaultValue;
|
private int _defaultValue;
|
||||||
|
|
||||||
private bool openedDropdown = false;
|
private bool openedDropdown = false;
|
||||||
|
@ -35,6 +36,14 @@ namespace HeavenStudio.Editor
|
||||||
// entity[propertyName].ChangeValues(dropdownEntity.Values);
|
// entity[propertyName].ChangeValues(dropdownEntity.Values);
|
||||||
_defaultValue = dropdownEntity.defaultValue;
|
_defaultValue = dropdownEntity.defaultValue;
|
||||||
EntityTypes.DropdownObj dropdownObj = entity[propertyName];
|
EntityTypes.DropdownObj dropdownObj = entity[propertyName];
|
||||||
|
|
||||||
|
int size = dropdownObj.Values.Count;
|
||||||
|
values = new int[size];
|
||||||
|
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
values[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
selected = dropdownObj.value;
|
selected = dropdownObj.value;
|
||||||
dropdown.AddOptions(dropdownObj.Values);
|
dropdown.AddOptions(dropdownObj.Values);
|
||||||
dropdown.onValueChanged.AddListener(newVal => dropdownObj.value = newVal);
|
dropdown.onValueChanged.AddListener(newVal => dropdownObj.value = newVal);
|
||||||
|
@ -50,11 +59,11 @@ namespace HeavenStudio.Editor
|
||||||
case Enum enumEntity:
|
case Enum enumEntity:
|
||||||
Type enumType = enumEntity.GetType();
|
Type enumType = enumEntity.GetType();
|
||||||
_defaultValue = (int)type;
|
_defaultValue = (int)type;
|
||||||
int[] keys = Enum.GetValues(enumType).Cast<int>().ToArray();
|
values = Enum.GetValues(enumType).Cast<int>().ToArray();
|
||||||
selected = Array.FindIndex(keys, val => val == (int)entity[propertyName]);
|
selected = Array.FindIndex(values, val => val == (int)entity[propertyName]);
|
||||||
|
|
||||||
dropdown.AddOptions(Enum.GetNames(enumType).ToList());
|
dropdown.AddOptions(Enum.GetNames(enumType).ToList());
|
||||||
dropdown.onValueChanged.AddListener(val => entity[propertyName] = keys[val]);
|
dropdown.onValueChanged.AddListener(val => entity[propertyName] = values[val]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -74,8 +83,8 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
public override void SetCollapses(object type)
|
public override void SetCollapses(object type)
|
||||||
{
|
{
|
||||||
dropdown.onValueChanged.AddListener(_ => UpdateCollapse(type));
|
dropdown.onValueChanged.AddListener(_ => UpdateCollapse(values[dropdown.value]));
|
||||||
UpdateCollapse(type);
|
UpdateCollapse(values[dropdown.value]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
|
|
Loading…
Reference in a new issue