Skip to content

Commit

Permalink
Merge pull request #53 from JasonMa0012/2.x
Browse files Browse the repository at this point in the history
Fix null reference errors
  • Loading branch information
JasonMa0012 authored Jul 24, 2024
2 parents 68577a3 + 617eb09 commit 31cb0b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 46 deletions.
56 changes: 11 additions & 45 deletions Editor/Helper/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,57 +177,22 @@ public static float PowPreserveSign(float f, float p)
// Tips: Use properties to fix null reference errors

private static GUIStyle _guiStyles_IconButton;

public static GUIStyle guiStyles_IconButton
{
get
{
if (_guiStyles_IconButton == null)
{
_guiStyles_IconButton = new GUIStyle(EditorStyles.iconButton) { fixedHeight = 0, fixedWidth = 0 };
}
return _guiStyles_IconButton;
}
}
public static GUIStyle guiStyles_IconButton => _guiStyles_IconButton ?? new GUIStyle(EditorStyles.iconButton) { fixedHeight = 0, fixedWidth = 0 };

private static GUIStyle _guiStyle_Foldout;

public static GUIStyle guiStyle_Foldout
public static GUIStyle guiStyle_Foldout => _guiStyle_Foldout ?? new GUIStyle(EditorStyles.miniButton)
{
get
{
if (_guiStyle_Foldout == null)
{
_guiStyle_Foldout =
new GUIStyle(EditorStyles.miniButton)
{
contentOffset = new Vector2(22, 0),
fixedHeight = 27,
alignment = TextAnchor.MiddleLeft,
font = EditorStyles.boldLabel.font,
fontSize = EditorStyles.boldLabel.fontSize + 1,
};
}
return _guiStyle_Foldout;
}
}
contentOffset = new Vector2(22, 0),
fixedHeight = 27,
alignment = TextAnchor.MiddleLeft,
font = EditorStyles.boldLabel.font,
fontSize = EditorStyles.boldLabel.fontSize + 1
};

private static GUIStyle _guiStyle_Helpbox;

public static GUIStyle guiStyle_Helpbox
{
get
{
if (_guiStyle_Helpbox == null)
{
_guiStyle_Helpbox = new GUIStyle(EditorStyles.helpBox) { fontSize = 12 };
}
return _guiStyle_Helpbox;
}
}
public static GUIStyle guiStyle_Helpbox => _guiStyle_Helpbox ?? new GUIStyle(EditorStyles.helpBox) { fontSize = 12 };

private static GUIStyle _guiStyles_ToolbarSearchTextFieldPopup;

public static GUIStyle guiStyles_ToolbarSearchTextFieldPopup
{
get
Expand Down Expand Up @@ -359,7 +324,8 @@ public static void DrawHelpbox(PropertyStaticData propertyStaticData, PropertyDy
}
}

private static Texture _logo = AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath("26b9d845eb7b1a747bf04dc84e5bcc2c"));
private static Texture _logoCache;
private static Texture _logo => _logoCache = _logoCache ?? AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath("26b9d845eb7b1a747bf04dc84e5bcc2c"));
private static GUIContent _logoGuiContent = new GUIContent(string.Empty, _logo,
"LWGUI (Light Weight Shader GUI)\n\n"
+ "A Lightweight, Flexible, Powerful Unity Shader GUI system.\n\n"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.jasonma.lwgui",
"version": "1.18.0",
"version": "1.18.1",
"displayName": "LWGUI",
"description": "A Lightweight, Flexible, Powerful Shader GUI System for Unity.",
"keywords": [
Expand Down

0 comments on commit 31cb0b2

Please sign in to comment.