Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
fuqunaga committed Aug 22, 2024
2 parents 6b3d458 + 60ceeb9 commit 9129e3e
Show file tree
Hide file tree
Showing 741 changed files with 6,331 additions and 3,908 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
max-parallel: 1
matrix:
pkg_root: [./Packages/RosettaUI, ./Packages/RosettaUI.UIToolkit]
pkg_root: [./Packages/ga.fuquna.rosettaui, ./Packages/ga.fuquna.rosettaui.uitoolkit]

steps:
- name: Checkout
Expand Down
2 changes: 2 additions & 0 deletions .idea/.idea.RosettaUI/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 47 additions & 6 deletions Assets/Example/Editor/RosettaUIEditorWindowExample.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using RosettaUI;
using RosettaUI.Editor;
Expand All @@ -15,18 +17,57 @@ public static void ShowExample()
}

public GameObject gameObject;
private Dictionary<Type, (ButtonElement button, Element element)> _typeToElementSet;

protected override Element CreateElement()
{
var types = RosettaUIExample.ExampleTypes;
var currentType = types.First();

_typeToElementSet = types.ToDictionary(
type => type,
type => (
UI.Button(
$"<align=left>{type.ToString().Split('.').Last()}</align>",
() => SetCurrentType(type)
),
(Element)UI.FieldIfObjectFound(type, includeInactive: true)
)
);

UpdateElements();

return UI.Tabs(
types.Select(type =>
return UI.ScrollView(ScrollViewType.VerticalAndHorizontal, new []
{
UI.Row(
UI.Column(
_typeToElementSet.Values.Select(pair => pair.button)
).SetWidth(200f),
UI.Page(
UI.Box(
_typeToElementSet.Values.Select(pair => pair.element)
)
)
)
});


void SetCurrentType(Type type)
{
if (type == currentType) return;
currentType = type;
UpdateElements();
}

void UpdateElements()
{
foreach (var (type, (button, e)) in _typeToElementSet)
{
var tabName = type.ToString().Split('.').Last();
return Tab.Create(tabName, () => UI.FieldIfObjectFound(type, false, true));
}).Concat(new[]{CreateUIEditorTab()})
);
var isCurrent = type == currentType;
button.SetBackgroundColor(isCurrent ? Color.gray : null);
e.Enable = isCurrent;
}
}
}

private Tab CreateUIEditorTab()
Expand Down
12 changes: 8 additions & 4 deletions Assets/Example/Runtime/Categories/BehaviourAnotherExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ namespace RosettaUI.Example
{
public class BehaviourAnotherExample : MonoBehaviour, IElementCreator
{
public string stringValue;
public float floatValue;

public Element CreateElement(LabelElement _)
=> UI.Column(
UI.Label(nameof(BehaviourAnotherExample)),
=> UI.Fold(nameof(BehaviourAnotherExample),
UI.FieldReadOnly(() => name),
UI.FieldReadOnly(() => isActiveAndEnabled)
);
UI.FieldReadOnly(() => isActiveAndEnabled),
UI.Field(() => stringValue),
UI.Field(() => floatValue)
).Open();
}
}
10 changes: 6 additions & 4 deletions Assets/Example/Runtime/Categories/BehaviourExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ namespace RosettaUI.Example
{
public class BehaviourExample : MonoBehaviour, IElementCreator
{
public string stringValue;

public Element CreateElement(LabelElement _)
=> UI.Column(
UI.Label(nameof(BehaviourExample)),
=> UI.Fold(nameof(BehaviourExample),
UI.FieldReadOnly(() => name),
UI.FieldReadOnly(() => isActiveAndEnabled)
);
UI.FieldReadOnly(() => isActiveAndEnabled),
UI.Field(() => stringValue)
).Open();
}
}
2 changes: 1 addition & 1 deletion Assets/Example/Runtime/Categories/CustomExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public Element CreateElement(LabelElement label)
public MyClass myClass;
using var propertyOrFieldsScope = new UICustom.PropertyOrFieldsScope<MyClass>(
""privateValue"",
""_privateValue"",
""publicValueNonSerialized"",
""PropertyValue""
);
Expand Down
12 changes: 5 additions & 7 deletions Assets/Example/Runtime/Categories/FieldExample.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Serialization;

namespace RosettaUI.Example
{
Expand Down Expand Up @@ -52,12 +50,12 @@ public class AttributeExampleClass
public float[] floatArray = {1f, 2f, 3f};
public SimpleClass simpleClass;

public List<SimpleClass> classList = new[]
public List<SimpleClass> classList = new List<SimpleClass>
{
new SimpleClass {floatValue = 1f, stringValue = "First"}
}.ToList();
new() { floatValue = 1f, stringValue = "First" }
};

[FormerlySerializedAs("attributeTestClass")] public AttributeExampleClass attributeExampleClass;
public AttributeExampleClass attributeExampleClass;


public Element CreateElement(LabelElement _)
Expand Down Expand Up @@ -114,7 +112,7 @@ public Element CreateElement(LabelElement _)
UI.FieldReadOnly(() => classList)
),
ExampleTemplate.Tab("Codes",
ExampleTemplate.CodeElementSets("Argument",
ExampleTemplate.CodeElementSets("Option",
"If FieldOption.delayInput == true, the value isn't updated until Enter is pressed or the focus is lost.",
(@"UI.Field(
() => intValue,
Expand Down
13 changes: 10 additions & 3 deletions Assets/Example/Runtime/Categories/LayoutExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ public Element CreateElement(LabelElement _)
)
),
ExampleTemplate.UIFunctionColumnBox(nameof(UI.Box),
UI.Label("box style frame")
UI.Row(
UI.Space().SetWidth(5f),
UI.Box(
UI.Label("box style frame")
)
)
),
ExampleTemplate.UIFunctionColumn(nameof(UI.Page),
UI.Label("Adjust the width of the prefix labels."),
Expand Down Expand Up @@ -230,17 +235,19 @@ Element CreateElement_ScrollView()

private Element CreateElement_FoldArgument()
{
var boolValue = false;
return ExampleTemplate.CodeElementSets("Fold argument",
(@"UI.Fold(
UI.Field(""CustomBar"", () => intValue),
UI.Toggle(""CustomBar"", () => boolValue),
new[]
{
UI.Label(""Element"")
}
);
",
UI.Fold(
UI.Field("CustomBar", () => intValue),
// UI.Field("CustomBar", () => intValue),
UI.Toggle("CustomBar", () => boolValue),
new[]
{
UI.Label("Element")
Expand Down
101 changes: 96 additions & 5 deletions Assets/Example/Runtime/Categories/ListExample.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace RosettaUI.Example
{
public class ListExample : MonoBehaviour, IElementCreator
{
public class NoCopyClass
{
public int intValue;
}

public class CloneableClass : ICloneable
{
public int intValue;
public object Clone() => new CloneableClass { intValue = this.intValue };
}

public class CopyConstructorClass
{
public int intValue;

public CopyConstructorClass() { }

public CopyConstructorClass(CopyConstructorClass other)
{
intValue = other.intValue;
}
}


public int[] intArray = {1, 2, 3};
public List<int> intList = new[] {1, 2, 3}.ToList();
public SimpleClass[] classArray = {new() {stringValue = "1"}, new() {stringValue = "2"}, new() {stringValue = "2"}};
public List<SimpleClass> classList = new SimpleClass[]{new() {stringValue = "1"}, new() {stringValue = "2"}, new() {stringValue = "2"}}.ToList();
public List<int> intList = new() {1, 2, 3};

public SimpleClass[] classArray =
{
new() {stringValue = "1"},
new() {stringValue = "2"},
new() {stringValue = "3"}
};

public List<SimpleClass> classList = new()
{
new SimpleClass {stringValue = "1"},
new SimpleClass {stringValue = "2"},
new SimpleClass {stringValue = "3"}
};

[NonReorderable]
public int[] nonReorderableArray = {1,2,3};

public Element CreateElement(LabelElement _)
{
var listViewOption = ListViewOption.Default;

List<NoCopyClass> noCopyClassList = new()
{
new NoCopyClass { intValue = 1 },
};

List<CloneableClass> cloneableClassList = new()
{
new CloneableClass { intValue = 1 },
};

List<CopyConstructorClass> copyConstructorClassList = new()
{
new CopyConstructorClass { intValue = 1 },
};


return UI.Tabs(
ExampleTemplate.UIFunctionTab(nameof(UI.List),
Expand All @@ -32,7 +84,7 @@ public Element CreateElement(LabelElement _)
UI.ListReadOnly(() => classArray),
UI.ListReadOnly(() => classList)
),
ExampleTemplate.Tab("Codes",
ExampleTemplate.Tab("Codes0",
ExampleTemplate.CodeElementSets("CustomItemElement",
(@"UI.List(() => intArray,
createItemElement: (itemBinder, idx) => UI.Row(
Expand All @@ -53,6 +105,7 @@ public Element CreateElement(LabelElement _)
(@"var listViewOption = ListViewOption.Default;
UI.Field(() => listViewOption).Open(),
UI.DynamicElementOnStatusChanged(
() => listViewOption,
_ => UI.List(() => intArray, listViewOption)
Expand All @@ -65,6 +118,44 @@ public Element CreateElement(LabelElement _)
)
)
)
)
),
ExampleTemplate.Tab("Codes1",
ExampleTemplate.CodeElementSets("<b>Duplicate previous item</b>",
"If the item implements ICloneable or has a copy constructor, it will copy its previous item when added.",
(@"public class NoCopyClass
{
public int intValue;
}
public class CloneableClass : ICloneable
{
public int intValue;
public object Clone() => new CloneableClass { intValue = this.intValue };
}
public class CopyConstructorClass
{
public int intValue;
public CopyConstructorClass() { }
public CopyConstructorClass(CopyConstructorClass other)
{
intValue = other.intValue;
}
}
UI.List(() => noCopyClassList);
UI.List(() => cloneableClassList);
UI.List(() => copyConstructorClassList);
",
UI.Column(
UI.List(() => noCopyClassList),
UI.List(() => cloneableClassList),
UI.List(() => copyConstructorClassList)
)
)
),
ExampleTemplate.CodeElementSets("<b>Attribute</b>",
(@"[NonReorderable]
Expand Down
32 changes: 31 additions & 1 deletion Assets/Example/Runtime/Categories/MinMaxSliderExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public Element CreateElement(LabelElement _)
{
SyntaxHighlighter.AddPattern("type", "MyMinMax");

var sliderOption = new SliderOption()
{
showInputField = false,
fieldOption = FieldOption.Default
};

return UI.Tabs(
ExampleTemplate.UIFunctionTab(nameof(UI.MinMaxSlider),
UI.MinMaxSlider(() => intMinMax),
Expand Down Expand Up @@ -67,7 +73,7 @@ public Element CreateElement(LabelElement _)
UI.MinMaxSliderReadOnly(() => boundsIntMinMax)
),
ExampleTemplate.Tab("Codes",
ExampleTemplate.CodeElementSets("Argument",
ExampleTemplate.CodeElementSets("Range",
(@"UI.MinMaxSlider(
() => floatMinMax,
range: MinMax.Create(-1f, 1f)
Expand All @@ -89,6 +95,30 @@ public Element CreateElement(LabelElement _)
).Open()
)
),
ExampleTemplate.CodeElementSets("Option",
(@"var sliderOption = new SliderOption()
{
showInputField = false,
fieldOption = FieldOption.Default
};
UI.Field(() => sliderOption).Open();
UI.DynamicElementOnStatusChanged(
() => sliderOption,
_ => UI.Slider(() => intMinMax, sliderOption)
.RegisterValueChangeCallback(() => Debug.Log($""OnValueChanged[{intMinMax}]""))
)",
UI.Column(
UI.Field(() => sliderOption).Open(),
UI.DynamicElementOnStatusChanged(
() => sliderOption,
_ => UI.MinMaxSlider(() => intMinMax, sliderOption)
.RegisterValueChangeCallback(() => Debug.Log($"OnValueChanged[{intMinMax}]"))
)
)
)
),
ExampleTemplate.CodeElementSets("Supported types",
$"Supports any type that has a specific member pair [{string.Join(",", TypeUtility.MinMaxMemberNamePairs.Select(pair => $"({pair.Item1}, {pair.Item2})"))}]",
(@"public struct MyMinMax<T>
Expand Down
Loading

0 comments on commit 9129e3e

Please sign in to comment.