Merge pull request #782 from RHeavenStudio/cherry-pick-release_1_patches-bc93a7ab940047372282ff27e2b66367ff89203c

Dropdown Fixes + TryGetMinigame
This commit is contained in:
minenice55 2024-03-12 18:58:55 +00:00 committed by GitHub
commit d75a06f7e6
3 changed files with 45 additions and 25 deletions

View file

@ -414,9 +414,9 @@ RectTransform:
m_Father: {fileID: 574002313}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: -21}
m_SizeDelta: {x: 32, y: 32}
m_Pivot: {x: 0, y: 0.5}
--- !u!114 &9435782
@ -3846,9 +3846,9 @@ RectTransform:
m_Father: {fileID: 539838476}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 32, y: -21}
m_SizeDelta: {x: 32, y: 32}
m_Pivot: {x: 1, y: 0.5}
--- !u!114 &121871281
@ -4070,9 +4070,9 @@ RectTransform:
m_Father: {fileID: 539838476}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 72, y: -21}
m_SizeDelta: {x: 32, y: 32}
m_Pivot: {x: 1, y: 0.5}
--- !u!114 &129013734
@ -4206,9 +4206,9 @@ RectTransform:
m_Father: {fileID: 539838476}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 112, y: -21}
m_SizeDelta: {x: 32, y: 32}
m_Pivot: {x: 1, y: 0.5}
--- !u!114 &151246938
@ -21329,7 +21329,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {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_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &781200687
@ -32090,7 +32090,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
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_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1244621693
@ -34621,9 +34621,9 @@ RectTransform:
m_Father: {fileID: 574002313}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 40, y: -21}
m_SizeDelta: {x: 32, y: 32}
m_Pivot: {x: 0, y: 0.5}
--- !u!114 &1345846031
@ -42945,9 +42945,9 @@ RectTransform:
m_Father: {fileID: 574002313}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 80, y: -21}
m_SizeDelta: {x: 32, y: 32}
m_Pivot: {x: 0, y: 0.5}
--- !u!114 &1783491359

View file

@ -1243,6 +1243,17 @@ namespace HeavenStudio
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;
public void SetCurrentGame(string game, bool useMinigameColor = true)
{

View file

@ -19,6 +19,7 @@ namespace HeavenStudio.Editor
public LeftClickTMP_Dropdown dropdown;
public Scrollbar scrollbar;
public int[] values;
private int _defaultValue;
private bool openedDropdown = false;
@ -35,6 +36,14 @@ namespace HeavenStudio.Editor
// entity[propertyName].ChangeValues(dropdownEntity.Values);
_defaultValue = dropdownEntity.defaultValue;
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;
dropdown.AddOptions(dropdownObj.Values);
dropdown.onValueChanged.AddListener(newVal => dropdownObj.value = newVal);
@ -50,11 +59,11 @@ namespace HeavenStudio.Editor
case Enum enumEntity:
Type enumType = enumEntity.GetType();
_defaultValue = (int)type;
int[] keys = Enum.GetValues(enumType).Cast<int>().ToArray();
selected = Array.FindIndex(keys, val => val == (int)entity[propertyName]);
values = Enum.GetValues(enumType).Cast<int>().ToArray();
selected = Array.FindIndex(values, val => val == (int)entity[propertyName]);
dropdown.AddOptions(Enum.GetNames(enumType).ToList());
dropdown.onValueChanged.AddListener(val => entity[propertyName] = keys[val]);
dropdown.onValueChanged.AddListener(val => entity[propertyName] = values[val]);
break;
default:
break;
@ -74,8 +83,8 @@ namespace HeavenStudio.Editor
public override void SetCollapses(object type)
{
dropdown.onValueChanged.AddListener(_ => UpdateCollapse(type));
UpdateCollapse(type);
dropdown.onValueChanged.AddListener(_ => UpdateCollapse(values[dropdown.value]));
UpdateCollapse(values[dropdown.value]);
}
private void Update()