sschmid / DesperateDevs

MIT License
18 stars 3 forks source link

EditorLayout.SearchTextField() method NullReferenceException #2

Closed lightjiao closed 1 year ago

lightjiao commented 1 year ago

Describe the bug EditorLayout.SearchTextField() method has code like below:

if (GUILayout.Button(string.Empty, GUI.skin.FindStyle("ToolbarSeachCancelButton")))

but there is no *.guiskin file, GUI.skin.FindStyle("ToolbarSeachCancelButton") will return null, then cause NullReferenceException

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.GUILayoutUtility.DoGetRect (UnityEngine.GUIContent content, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at <82a3a4e0a0a94de5afddd345f6cf50d1>:0)
UnityEngine.GUILayoutUtility.GetRect (UnityEngine.GUIContent content, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at <82a3a4e0a0a94de5afddd345f6cf50d1>:0)
UnityEngine.GUILayout.DoTextField (System.String text, System.Int32 maxLength, System.Boolean multiline, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at <82a3a4e0a0a94de5afddd345f6cf50d1>:0)
UnityEngine.GUILayout.TextField (System.String text, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at <82a3a4e0a0a94de5afddd345f6cf50d1>:0)

I use Entitas.Generic instead code generator ( more conviance with little performance price ) I don't find any *.guiskin in source code, can you help me to solve the problem?

*Unity Version: 2022.3.4f1 and 2021.3.28f1

sschmid commented 1 year ago

@lightjiao See this issue for and updated dll that fixes this: https://github.com/sschmid/Entitas/issues/1067#issuecomment-1623734894

sschmid commented 1 year ago

I just checked the Entitas repo you linked and it hasn't been updated in many years. Please try the dll I linked in the issue, but there's a chance it's not compatible anymore because the repo is so old.

Alternatively, try using Unity Version 2022.3.2f1. I think Unity introduced this breaking change in 2022.3.3 or 2022.3.4

sschmid commented 1 year ago

If it doesn't work, I can try to provide a fixed version of the old DesperateDevs dll for you

lightjiao commented 1 year ago

It solve my problem perfectly, thanks a lot.

by the way, the Entitas.Generic repo only use the core API of entitas, it is very simple and easy to use. I simplified it's API, looks good for me.

JesseTG commented 1 year ago

Could you put out a new release of this repo that includes the fix?