Skip to content

Commit f3021f8

Browse files
committed
Fix Unity 6.1+ Compile Errors
1 parent 1559871 commit f3021f8

File tree

7 files changed

+80
-62
lines changed

7 files changed

+80
-62
lines changed

Editor/Helper/Helper.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using LWGUI.Timeline;
88
using UnityEditor;
99
using UnityEngine;
10+
using UnityEngine.Rendering;
1011
using Object = UnityEngine.Object;
1112

1213
namespace LWGUI
@@ -23,7 +24,7 @@ public static class Helper
2324

2425
public static bool IsPropertyHideInInspector(MaterialProperty prop)
2526
{
26-
return (prop.flags & MaterialProperty.PropFlags.HideInInspector) != 0;
27+
return (prop.GetPropertyFlags() & ShaderPropertyFlags.HideInInspector) != 0;
2728
}
2829

2930
public static string GetKeywordName(string keyword, string propName)
@@ -461,10 +462,10 @@ private static void DoPasteMaterialProperties(LWGUIMetaDatas metaDatas, uint val
461462
Undo.RecordObjects(targetMaterials, "LWGUI: Paste Material Properties");
462463
foreach (Material material in targetMaterials)
463464
{
464-
for (int i = 0; i < ShaderUtil.GetPropertyCount(_copiedMaterial.shader); i++)
465+
for (int i = 0; i < _copiedMaterial.shader.GetPropertyCount(); i++)
465466
{
466-
var name = ShaderUtil.GetPropertyName(_copiedMaterial.shader, i);
467-
var type = ShaderUtil.GetPropertyType(_copiedMaterial.shader, i);
467+
var name = _copiedMaterial.shader.GetPropertyName(i);
468+
var type = _copiedMaterial.shader.GetPropertyType(i);
468469
PastePropertyValueToMaterial(material, name, name, type, valueMask);
469470
}
470471
if ((valueMask & (uint)CopyMaterialValueMask.Keyword) != 0)
@@ -476,31 +477,31 @@ private static void DoPasteMaterialProperties(LWGUIMetaDatas metaDatas, uint val
476477

477478
private static void PastePropertyValueToMaterial(Material material, string srcName, string dstName)
478479
{
479-
for (int i = 0; i < ShaderUtil.GetPropertyCount(_copiedMaterial.shader); i++)
480+
for (int i = 0; i < _copiedMaterial.shader.GetPropertyCount(); i++)
480481
{
481-
var name = ShaderUtil.GetPropertyName(_copiedMaterial.shader, i);
482+
var name = _copiedMaterial.shader.GetPropertyName(i);
482483
if (name == srcName)
483484
{
484-
var type = ShaderUtil.GetPropertyType(_copiedMaterial.shader, i);
485+
var type = _copiedMaterial.shader.GetPropertyType(i);
485486
PastePropertyValueToMaterial(material, srcName, dstName, type);
486487
return;
487488
}
488489
}
489490
}
490491

491-
private static void PastePropertyValueToMaterial(Material material, string srcName, string dstName, ShaderUtil.ShaderPropertyType type, uint valueMask = (uint)CopyMaterialValueMask.All)
492+
private static void PastePropertyValueToMaterial(Material material, string srcName, string dstName, ShaderPropertyType type, uint valueMask = (uint)CopyMaterialValueMask.All)
492493
{
493494
switch (type)
494495
{
495-
case ShaderUtil.ShaderPropertyType.Color:
496+
case ShaderPropertyType.Color:
496497
if ((valueMask & (uint)CopyMaterialValueMask.Vector) != 0)
497498
material.SetColor(dstName, _copiedMaterial.GetColor(srcName));
498499
break;
499-
case ShaderUtil.ShaderPropertyType.Vector:
500+
case ShaderPropertyType.Vector:
500501
if ((valueMask & (uint)CopyMaterialValueMask.Vector) != 0)
501502
material.SetVector(dstName, _copiedMaterial.GetVector(srcName));
502503
break;
503-
case ShaderUtil.ShaderPropertyType.TexEnv:
504+
case ShaderPropertyType.Texture:
504505
if ((valueMask & (uint)CopyMaterialValueMask.Texture) != 0)
505506
material.SetTexture(dstName, _copiedMaterial.GetTexture(srcName));
506507
break;

Editor/Helper/RevertableHelper.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using UnityEditor;
66
using UnityEngine;
7+
using UnityEngine.Rendering;
78

89
namespace LWGUI
910
{
@@ -57,12 +58,12 @@ public static void SetRevertableGUIWidths()
5758
EditorGUIUtility.labelWidth = RevertableHelper.labelWidth;
5859
}
5960

60-
public static void FixGUIWidthMismatch(MaterialProperty.PropType propType, MaterialEditor materialEditor)
61+
public static void FixGUIWidthMismatch(ShaderPropertyType propType, MaterialEditor materialEditor)
6162
{
6263
switch (propType)
6364
{
64-
case MaterialProperty.PropType.Texture:
65-
case MaterialProperty.PropType.Range:
65+
case ShaderPropertyType.Texture:
66+
case ShaderPropertyType.Range:
6667
materialEditor.SetDefaultGUIWidths();
6768
break;
6869
default:
@@ -88,22 +89,22 @@ public static void SetPropertyToDefault(MaterialProperty defaultProp, MaterialPr
8889
public static string GetPropertyDefaultValueText(MaterialProperty defaultProp)
8990
{
9091
string defaultText = String.Empty;
91-
switch (defaultProp.type)
92+
switch (defaultProp.GetPropertyType())
9293
{
93-
case MaterialProperty.PropType.Color:
94+
case ShaderPropertyType.Color:
9495
defaultText = defaultProp.colorValue.ToString();
9596
break;
96-
case MaterialProperty.PropType.Float:
97-
case MaterialProperty.PropType.Range:
97+
case ShaderPropertyType.Float:
98+
case ShaderPropertyType.Range:
9899
defaultText = defaultProp.floatValue.ToString();
99100
break;
100-
case MaterialProperty.PropType.Int:
101+
case ShaderPropertyType.Int:
101102
defaultText = defaultProp.intValue.ToString();
102103
break;
103-
case MaterialProperty.PropType.Texture:
104+
case ShaderPropertyType.Texture:
104105
defaultText = defaultProp.textureValue != null ? defaultProp.textureValue.name : "None";
105106
break;
106-
case MaterialProperty.PropType.Vector:
107+
case ShaderPropertyType.Vector:
107108
defaultText = defaultProp.vectorValue.ToString();
108109
break;
109110
}

Editor/LWGUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private void DrawProperty(MaterialProperty prop)
171171
Helper.BeginProperty(rect, prop, metaDatas);
172172
Helper.DoPropertyContextMenus(rect, prop, metaDatas);
173173

174-
RevertableHelper.FixGUIWidthMismatch(prop.type, materialEditor);
174+
RevertableHelper.FixGUIWidthMismatch(prop.GetPropertyType(), materialEditor);
175175
if (propStaticData.isAdvancedHeaderProperty)
176176
propStaticData.isExpanding = EditorGUI.Foldout(rect, propStaticData.isExpanding, string.Empty);
177177

Editor/ScriptableObject/LwguiShaderPropertyPreset.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.Linq;
55
using UnityEngine;
6+
using UnityEngine.Rendering;
67
using UnityEditor;
78
using Object = UnityEngine.Object;
89

@@ -115,29 +116,29 @@ public void Apply(Material material, bool isDefaultMaterial, PerMaterialData per
115116
public void CopyFromMaterialProperty(MaterialProperty prop)
116117
{
117118
propertyName = prop.name;
118-
switch (prop.type)
119+
switch (prop.GetPropertyType())
119120
{
120-
case MaterialProperty.PropType.Color:
121+
case ShaderPropertyType.Color:
121122
propertyType = PropertyType.Color;
122123
colorValue = prop.colorValue;
123124
break;
124-
case MaterialProperty.PropType.Vector:
125+
case ShaderPropertyType.Vector:
125126
propertyType = PropertyType.Vector;
126127
vectorValue = prop.vectorValue;
127128
break;
128-
case MaterialProperty.PropType.Float:
129+
case ShaderPropertyType.Float:
129130
propertyType = PropertyType.Float;
130131
floatValue = prop.floatValue;
131132
break;
132-
case MaterialProperty.PropType.Int:
133+
case ShaderPropertyType.Int:
133134
propertyType = PropertyType.Integer;
134135
intValue = prop.intValue;
135136
break;
136-
case MaterialProperty.PropType.Range:
137+
case ShaderPropertyType.Range:
137138
propertyType = PropertyType.Range;
138139
floatValue = prop.floatValue;
139140
break;
140-
case MaterialProperty.PropType.Texture:
141+
case ShaderPropertyType.Texture:
141142
propertyType = PropertyType.Texture;
142143
textureValue = prop.textureValue;
143144
break;

Editor/ShaderDrawer.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public SubDrawer(string group)
171171
protected virtual float GetVisibleHeight(MaterialProperty prop)
172172
{
173173
var height = MaterialEditor.GetDefaultPropertyHeight(prop);
174-
return prop.type == MaterialProperty.PropType.Vector ? EditorGUIUtility.singleLineHeight : height;
174+
return prop.GetPropertyType() == ShaderPropertyType.Vector ? EditorGUIUtility.singleLineHeight : height;
175175
}
176176

177177
public virtual void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData)
@@ -194,7 +194,7 @@ public override void OnGUI(Rect position, MaterialProperty prop, GUIContent labe
194194
}
195195
else
196196
{
197-
Debug.LogWarning("LWGUI: Property:'" + prop.name + "' Type:'" + prop.type + "' mismatch!");
197+
Debug.LogWarning("LWGUI: Property:'" + prop.name + "' Type:'" + prop.GetPropertyType() + "' mismatch!");
198198
editor.DefaultShaderProperty(position, prop, label.text);
199199
}
200200
}
@@ -207,7 +207,7 @@ public override float GetPropertyHeight(MaterialProperty prop, string label, Mat
207207
// Draws a custom style property
208208
public virtual void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
209209
{
210-
RevertableHelper.FixGUIWidthMismatch(prop.type, editor);
210+
RevertableHelper.FixGUIWidthMismatch(prop.GetPropertyType(), editor);
211211
editor.DefaultShaderPropertyInternal(position, prop, label);
212212
}
213213
}
@@ -244,7 +244,7 @@ public SubToggleDrawer(string group, string keyWord, string presetFileName)
244244

245245
protected override bool IsMatchPropType(MaterialProperty property)
246246
{
247-
return property.type is MaterialProperty.PropType.Float;
247+
return property.GetPropertyType() is ShaderPropertyType.Float;
248248
}
249249

250250
public override void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData)
@@ -307,11 +307,11 @@ public SubPowerSliderDrawer(string group, float power)
307307
this._power = Mathf.Clamp(power, 0, float.MaxValue);
308308
}
309309

310-
protected override bool IsMatchPropType(MaterialProperty property) { return property.type == MaterialProperty.PropType.Range; }
310+
protected override bool IsMatchPropType(MaterialProperty property) { return property.GetPropertyType() == ShaderPropertyType.Range; }
311311

312312
public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
313313
{
314-
RevertableHelper.FixGUIWidthMismatch(prop.type, editor);
314+
RevertableHelper.FixGUIWidthMismatch(prop.GetPropertyType(), editor);
315315
EditorGUI.showMixedValue = prop.hasMixedValue;
316316
var rect = position;
317317
ReflectionHelper.DoPowerRangeProperty(rect, prop, label, _power);
@@ -332,13 +332,13 @@ public SubIntRangeDrawer(string group)
332332
this.group = group;
333333
}
334334

335-
protected override bool IsMatchPropType(MaterialProperty property) { return property.type == MaterialProperty.PropType.Range; }
335+
protected override bool IsMatchPropType(MaterialProperty property) { return property.GetPropertyType() == ShaderPropertyType.Range; }
336336

337337
public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
338338
{
339-
RevertableHelper.FixGUIWidthMismatch(prop.type, editor);
339+
RevertableHelper.FixGUIWidthMismatch(prop.GetPropertyType(), editor);
340340

341-
if (prop.type != MaterialProperty.PropType.Range)
341+
if (prop.GetPropertyType() != ShaderPropertyType.Range)
342342
{
343343
EditorGUI.LabelField(position, "IntRange used on a non-range property: " + prop.name, EditorStyles.helpBox);
344344
}
@@ -382,7 +382,7 @@ public MinMaxSliderDrawer(string group, string minPropName, string maxPropName)
382382
this._maxPropName = maxPropName;
383383
}
384384

385-
protected override bool IsMatchPropType(MaterialProperty property) { return property.type == MaterialProperty.PropType.Range; }
385+
protected override bool IsMatchPropType(MaterialProperty property) { return property.GetPropertyType() == ShaderPropertyType.Range; }
386386

387387
public override void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData)
388388
{
@@ -553,7 +553,7 @@ protected void Init(string group, string[] names, string[] keyWords, float[] val
553553
this._values = values;
554554
}
555555

556-
protected override bool IsMatchPropType(MaterialProperty property) { return property.type is MaterialProperty.PropType.Float; }
556+
protected override bool IsMatchPropType(MaterialProperty property) { return property.GetPropertyType() is ShaderPropertyType.Float; }
557557

558558
protected virtual string GetKeywordName(string propName, string name) { return (name).Replace(' ', '_').ToUpperInvariant(); }
559559

@@ -732,7 +732,7 @@ public static void ApplyPreset(string presetFileName, MaterialProperty prop)
732732
}
733733
}
734734

735-
protected override bool IsMatchPropType(MaterialProperty property) { return property.type == MaterialProperty.PropType.Float; }
735+
protected override bool IsMatchPropType(MaterialProperty property) { return property.GetPropertyType() == ShaderPropertyType.Float; }
736736

737737
public override void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData)
738738
{
@@ -878,7 +878,7 @@ public BitMaskDrawer(string group, List<string> bitDescriptions)
878878
totalButtonWidth = buttonWidths.Sum();
879879
}
880880

881-
protected override bool IsMatchPropType(MaterialProperty property) { return property.type == MaterialProperty.PropType.Int; }
881+
protected override bool IsMatchPropType(MaterialProperty property) { return property.GetPropertyType() == ShaderPropertyType.Int; }
882882

883883
protected override float GetVisibleHeight(MaterialProperty prop) { return maxHeight; }
884884

@@ -949,7 +949,7 @@ public LwguiRampAtlas rampAtlasSO
949949
if (!_rampAtlasSO)
950950
{
951951
var rampAtlasProp = metaDatas.GetProperty(rampAtlasPropName);
952-
if (rampAtlasProp != null && rampAtlasProp.type == MaterialProperty.PropType.Texture)
952+
if (rampAtlasProp != null && rampAtlasProp.GetPropertyType() == ShaderPropertyType.Texture)
953953
{
954954
_rampAtlasSO = LwguiRampAtlas.LoadRampAtlasSO(rampAtlasProp.textureValue);
955955
}
@@ -995,7 +995,7 @@ public RampAtlasIndexerDrawer(string group, string rampAtlasPropName, string def
995995
}
996996
}
997997

998-
protected override bool IsMatchPropType(MaterialProperty property) => property.type is MaterialProperty.PropType.Float or MaterialProperty.PropType.Int;
998+
protected override bool IsMatchPropType(MaterialProperty property) => property.GetPropertyType() is ShaderPropertyType.Float or ShaderPropertyType.Int;
999999

10001000
protected override void OnRampPropUpdate(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
10011001
{
@@ -1118,7 +1118,7 @@ protected override void DrawPreviewTextureOverride(Rect previewRect, MaterialPro
11181118
public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
11191119
{
11201120
var rampAtlasProp = metaDatas.GetProperty(rampAtlasPropName);
1121-
if (rampAtlasProp == null || rampAtlasProp.type != MaterialProperty.PropType.Texture)
1121+
if (rampAtlasProp == null || rampAtlasProp.GetPropertyType() != ShaderPropertyType.Texture)
11221122
{
11231123
Helper.DrawShaderPropertyWithErrorLabel(position, prop, label, editor, "Invalid rampAtlasPropName");
11241124
Debug.LogError($"LWGUI: Property { prop.name } has invalid rampAtlasPropName: { rampAtlasPropName }");
@@ -1182,7 +1182,7 @@ public TexDrawer(string group, string extraPropName)
11821182

11831183
protected override float GetVisibleHeight(MaterialProperty prop) { return EditorGUIUtility.singleLineHeight; }
11841184

1185-
protected override bool IsMatchPropType(MaterialProperty property) { return property.type == MaterialProperty.PropType.Texture; }
1185+
protected override bool IsMatchPropType(MaterialProperty property) { return property.GetPropertyType() == ShaderPropertyType.Texture; }
11861186

11871187
public override void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData)
11881188
{
@@ -1196,7 +1196,7 @@ public override void GetDefaultValueDescription(Shader inShader, MaterialPropert
11961196
if (defaultExtraProp != null)
11971197
{
11981198
var text = string.Empty;
1199-
if (defaultExtraProp.type == MaterialProperty.PropType.Vector)
1199+
if (defaultExtraProp.GetPropertyType() == ShaderPropertyType.Vector)
12001200
text = ChannelDrawer.GetChannelName(defaultExtraProp);
12011201
else
12021202
text = RevertableHelper.GetPropertyDefaultValueText(defaultExtraProp);
@@ -1225,7 +1225,7 @@ public override void DrawProp(Rect position, MaterialProperty prop, GUIContent l
12251225
var extraRect = MaterialEditor.GetRightAlignedFieldRect(rect);
12261226
extraRect.height = rect.height;
12271227

1228-
if (extraProp.type == MaterialProperty.PropType.Vector)
1228+
if (extraProp.GetPropertyType() == ShaderPropertyType.Vector)
12291229
_channelDrawer.OnGUI(extraRect, extraProp, GUIContent.none, editor);
12301230
else
12311231
editor.ShaderProperty(extraRect, extraProp, GUIContent.none);
@@ -1321,7 +1321,7 @@ public RampDrawer(string group, string defaultFileName, string rootPath, string
13211321
}
13221322
}
13231323

1324-
protected override bool IsMatchPropType(MaterialProperty property) { return property.type == MaterialProperty.PropType.Texture; }
1324+
protected override bool IsMatchPropType(MaterialProperty property) { return property.GetPropertyType() == ShaderPropertyType.Texture; }
13251325

13261326
protected virtual void OnRampPropUpdate(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { }
13271327

@@ -1580,7 +1580,7 @@ public RampAtlasDrawer(string group, string defaultFileName, string rootPath, st
15801580
this.defaultAtlasHeight = (int)Mathf.Max(2, defaultHeight);
15811581
}
15821582

1583-
protected override bool IsMatchPropType(MaterialProperty property) => property.type == MaterialProperty.PropType.Texture;
1583+
protected override bool IsMatchPropType(MaterialProperty property) => property.GetPropertyType() == ShaderPropertyType.Texture;
15841584

15851585
protected override float GetVisibleHeight(MaterialProperty prop) =>
15861586
EditorGUIUtility.singleLineHeight + 2.0f +
@@ -1742,7 +1742,7 @@ public ColorDrawer(string group, string color2, string color3, string color4)
17421742
this._colorStrings[2] = color4;
17431743
}
17441744

1745-
protected override bool IsMatchPropType(MaterialProperty property) { return property.type == MaterialProperty.PropType.Color; }
1745+
protected override bool IsMatchPropType(MaterialProperty property) { return property.GetPropertyType() == ShaderPropertyType.Color; }
17461746

17471747
public override void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData)
17481748
{
@@ -1786,7 +1786,7 @@ public override void DrawProp(Rect position, MaterialProperty prop, GUIContent l
17861786
r.xMax -= w * i - interval;
17871787

17881788
var src = cProp.colorValue;
1789-
var isHdr = (colorArray[i].flags & MaterialProperty.PropFlags.HDR) != MaterialProperty.PropFlags.None;
1789+
var isHdr = (colorArray[i].GetPropertyFlags() & ShaderPropertyFlags.HDR) != ShaderPropertyFlags.None;
17901790
var dst = EditorGUI.ColorField(r, GUIContent.none, src, true, true, isHdr);
17911791
if (Helper.EndChangeCheck(metaDatas, cProp))
17921792
{
@@ -1842,7 +1842,7 @@ public ChannelDrawer(string group)
18421842
this.group = group;
18431843
}
18441844

1845-
protected override bool IsMatchPropType(MaterialProperty property) { return property.type == MaterialProperty.PropType.Vector; }
1845+
protected override bool IsMatchPropType(MaterialProperty property) { return property.GetPropertyType() == ShaderPropertyType.Vector; }
18461846

18471847
private static int GetChannelIndex(MaterialProperty prop)
18481848
{
@@ -2241,8 +2241,8 @@ public PassSwitchDecorator(string lightModeName1, string lightModeName2, string
22412241

22422242
protected override bool IsMatchPropType(MaterialProperty property)
22432243
{
2244-
return property.type == MaterialProperty.PropType.Float
2245-
|| property.type == MaterialProperty.PropType.Int;
2244+
return property.GetPropertyType() == ShaderPropertyType.Float
2245+
|| property.GetPropertyType() == ShaderPropertyType.Int;
22462246
}
22472247

22482248
public override void BuildStaticMetaData(Shader inShader, MaterialProperty inProp, MaterialProperty[] inProps, PropertyStaticData inoutPropertyStaticData) { }

0 commit comments

Comments
 (0)