Skip to content

Commit 1a1fbe0

Browse files
committed
Add BitMask()
Add Integer support for Presets
1 parent f2e3bd1 commit 1a1fbe0

19 files changed

+565
-101
lines changed

Editor/Helper/Helper.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public static GUIStyle guiStyles_ToolbarSearchTextFieldPopup
227227
#endregion
228228

229229

230-
#region Draw GUI for Drawer
230+
#region Draw GUI for Drawers
231231

232232
// TODO: use Reflection
233233
// copy and edit of https://github.com/GucioDevs/SimpleMinMaxSlider/blob/master/Assets/SimpleMinMaxSlider/Scripts/Editor/MinMaxSliderDrawer.cs
@@ -298,10 +298,25 @@ public static bool DrawFoldout(Rect rect, ref bool isFolding, bool toggleValue,
298298
return toggleValue;
299299
}
300300

301+
public static bool ToggleButton(Rect position, GUIContent label, bool on, GUIStyle style = null, float padding = 0)
302+
{
303+
var paddedRect = new Rect(position.x + padding, position.y, position.width - padding * 2, position.height);
304+
style ??= EditorStyles.miniButton;
305+
306+
bool flag = GUI.Button(paddedRect, label, style);
307+
if (Event.current.type == EventType.Repaint)
308+
{
309+
bool isHover = paddedRect.Contains(Event.current.mousePosition);
310+
style.Draw(position, label, isHover, false, on, false);
311+
}
312+
313+
return flag;
314+
}
315+
301316
#endregion
302317

303318

304-
#region Draw GUI for Material
319+
#region Draw GUI for Materials
305320

306321
public static void DrawSplitLine()
307322
{

Editor/ScriptableObject/ShaderPropertyPreset.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using LWGUI.Timeline;
65
using UnityEngine;
76
using UnityEditor;
87
using Object = UnityEngine.Object;
@@ -19,6 +18,7 @@ public enum PropertyType
1918
Float,
2019
Range,
2120
Texture,
21+
Integer,
2222
}
2323

2424
[Serializable]
@@ -32,6 +32,7 @@ public PropertyValue(MaterialProperty prop)
3232
public string propertyName;
3333
public PropertyType propertyType;
3434
public float floatValue;
35+
public int intValue;
3536
public Color colorValue;
3637
public Vector4 vectorValue;
3738
public Texture textureValue;
@@ -72,6 +73,9 @@ public void Apply(Material material, bool isDefaultMaterial, PerMaterialData per
7273
case PropertyType.Range:
7374
material.SetFloat(propertyNameID, floatValue);
7475
break;
76+
case PropertyType.Integer:
77+
material.SetInteger(propertyNameID, intValue);
78+
break;
7579
case PropertyType.Texture:
7680
material.SetTexture(propertyNameID, textureValue);
7781
break;
@@ -96,6 +100,9 @@ public void Apply(Material material, bool isDefaultMaterial, PerMaterialData per
96100
case PropertyType.Range:
97101
prop.floatValue = floatValue;
98102
break;
103+
case PropertyType.Integer:
104+
prop.intValue = intValue;
105+
break;
99106
case PropertyType.Texture:
100107
prop.textureValue = textureValue;
101108
break;
@@ -118,11 +125,14 @@ public void CopyFromMaterialProperty(MaterialProperty prop)
118125
propertyType = PropertyType.Vector;
119126
vectorValue = prop.vectorValue;
120127
break;
121-
case MaterialProperty.PropType.Int:
122128
case MaterialProperty.PropType.Float:
123129
propertyType = PropertyType.Float;
124130
floatValue = prop.floatValue;
125131
break;
132+
case MaterialProperty.PropType.Int:
133+
propertyType = PropertyType.Integer;
134+
intValue = prop.intValue;
135+
break;
126136
case MaterialProperty.PropType.Range:
127137
propertyType = PropertyType.Range;
128138
floatValue = prop.floatValue;

0 commit comments

Comments
 (0)