Skip to content

Commit

Permalink
UI for gradients added + UI cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vyshnovka committed Feb 14, 2024
1 parent eed2e36 commit e7d5339
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 33 deletions.
47 changes: 21 additions & 26 deletions Assets/Scenes/Generation.unity
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
terrain: {fileID: 305544099}
texture: {fileID: 2800000, guid: e6ff0d19c97771446a91455cd7547bea, type: 3}
selectedAlgorithmType: 0
selectedSize: 32
selectedGradientType: 0
grayscale:
serializedVersion: 2
gradients:
- serializedVersion: 2
key0: {r: 0, g: 0, b: 0, a: 1}
key1: {r: 1, g: 1, b: 1, a: 1}
key2: {r: 0, g: 0, b: 0, a: 0}
Expand Down Expand Up @@ -550,22 +547,21 @@ MonoBehaviour:
m_ColorSpace: -1
m_NumColorKeys: 2
m_NumAlphaKeys: 2
mountains:
serializedVersion: 2
key0: {r: 0.32644656, g: 0.5849056, b: 0.16921796, a: 1}
key1: {r: 0.60784316, g: 0.8509804, b: 0.29411766, a: 1}
key2: {r: 0.9764706, g: 0.8509804, b: 0.14509805, a: 0}
key3: {r: 0.9019608, g: 0.47843137, b: 0.27058825, a: 0}
key4: {r: 0.8392157, g: 0.32156864, b: 0.28627452, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
- serializedVersion: 2
key0: {r: 0.65882355, g: 0.9490196, b: 0.9490196, a: 1}
key1: {r: 0.78431374, g: 0.9490196, b: 0.3764706, a: 1}
key2: {r: 0.92156863, g: 0.85882354, b: 0.32156864, a: 0}
key3: {r: 0.98039216, g: 0.7019608, b: 0.29411766, a: 0}
key4: {r: 0.88235295, g: 0.38431373, b: 0.2, a: 0}
key5: {r: 0.6156863, g: 0.101960786, b: 0.101960786, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 16384
ctime2: 32768
ctime3: 49151
ctime4: 65535
ctime5: 0
ctime1: 13107
ctime2: 26214
ctime3: 39321
ctime4: 52428
ctime5: 65535
ctime6: 0
ctime7: 0
atime0: 0
Expand All @@ -578,15 +574,14 @@ MonoBehaviour:
atime7: 0
m_Mode: 0
m_ColorSpace: -1
m_NumColorKeys: 5
m_NumColorKeys: 6
m_NumAlphaKeys: 2
water:
serializedVersion: 2
key0: {r: 0.017399997, g: 0.09169653, b: 0.12, a: 1}
key1: {r: 0.044999994, g: 0.21930383, b: 0.3, a: 1}
key2: {r: 0.20054583, g: 0.48584285, b: 0.6132076, a: 0}
key3: {r: 0.42013758, g: 0.7461807, b: 0.9150943, a: 0}
key4: {r: 0.8930817, g: 0.9592692, b: 1, a: 0}
- serializedVersion: 2
key0: {r: 0.10980392, g: 0.105882354, b: 0.10980392, a: 1}
key1: {r: 0.13725491, g: 0.15686275, b: 0.1882353, a: 1}
key2: {r: 0.15294118, g: 0.23529412, b: 0.30980393, a: 0}
key3: {r: 0.1254902, g: 0.32156864, b: 0.45882353, a: 0}
key4: {r: 0, g: 0.47058824, b: 0.67058825, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
Expand Down
6 changes: 4 additions & 2 deletions Assets/Scripts/Managers/UIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ void OnEnable()
algorithmDropdown.value = (Enum)Enum.Parse(algorithmDropdown.value.GetType(), terrainGenerator.SelectedAlgorithmTypeAsName);

var sizeDropdown = root.Q<EnumField>("SizeEnum");
sizeDropdown.RegisterValueChangedCallback(evt => terrainGenerator.SelectedSizeAsNumber = Convert.ToInt32(evt.newValue));
sizeDropdown.RegisterValueChangedCallback(_ => terrainGenerator.SelectedSizeAsNumber = Convert.ToInt32(_.newValue));
sizeDropdown.value = (Enum)Enum.ToObject(sizeDropdown.value.GetType(), terrainGenerator.SelectedSizeAsNumber);

//TODO Logic for gradient radio buttons.
var gradientDropdown = root.Q<EnumField>("GradientEnum");
gradientDropdown.RegisterValueChangedCallback(_ => terrainGenerator.SelectedGradientTypeAsNumber = Convert.ToInt32(_.newValue));
gradientDropdown.value = (Enum)Enum.ToObject(gradientDropdown.value.GetType(), terrainGenerator.SelectedGradientTypeAsNumber);
}

void OnDisable()
Expand Down
5 changes: 5 additions & 0 deletions Assets/UI Toolkit/CommonStyleSheet.uss
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@
width: 30%;
height: 80%;
}

#unity-radio-button-group__container {
flex-direction: row;
justify-content: space-around;
}
6 changes: 1 addition & 5 deletions Assets/UI Toolkit/CommonUI.uxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
<ui:VisualElement name="Settings" style="width: 23%; height: 35%; background-color: rgba(255, 255, 255, 0.04); justify-content: space-around; align-items: center; color: rgba(123, 123, 123, 0.54); background-image: url(&apos;project://database/Assets/Images/White.png?fileID=21300000&amp;guid=9bce4995469076848b32d0fdf6220e69&amp;type=3#White&apos;); -unity-background-image-tint-color: rgba(255, 255, 255, 0.04);">
<ui:EnumField label="Algorithm Type" type="SharedDefs.AlgorithmType, Assembly-CSharp" name="AlgorithmEnum" class="smallContainer dropdownBox textSmall" />
<ui:EnumField label="Terrain Size" type="SharedDefs.Size, Assembly-CSharp" name="SizeEnum" class="smallContainer dropdownBox textSmall" />
<ui:GroupBox name="GradientGroupBox" class="smallContainer textSmall" style="flex-direction: row; margin-top: 0; margin-bottom: 0; padding-left: 0; padding-top: 0; padding-bottom: 0;">
<ui:RadioButton label="Grayscale" name="GrayscaleRadio" value="true" class="radioButton textSmall" />
<ui:RadioButton label="Mountains" name="MountainsRadio" value="false" class="radioButton textSmall" />
<ui:RadioButton label="Water" name="WaterRadio" value="false" class="radioButton textSmall" />
</ui:GroupBox>
<ui:EnumField label="Color Scheme" type="SharedDefs.GradientType, Assembly-CSharp" name="GradientEnum" class="smallContainer dropdownBox textSmall" />
<ui:Button text="GENERATE" display-tooltip-when-elided="true" name="Generate" class="textSmall" style="margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 5%; padding-left: 0; padding-right: 0; padding-top: 0; padding-bottom: 0; width: 40%; height: 15%;" />
</ui:VisualElement>
<ui:VisualElement name="PopupContainer" style="flex-grow: 1; height: 100%; justify-content: center; align-items: center;">
Expand Down

0 comments on commit e7d5339

Please sign in to comment.