Question by
Filip-Zelinka · Sep 20, 2017 at 11:46 AM ·
editorflickeringglitchingobjectfield
Sprite objectfield flickers in custom inspector editor.
Hi, I got this annoying issue with editor. I got Custom Inspector Editor for simple ScriptableObject. And Sprite Object fields keep flickering, hiding and showing selected sprite and showing blue selection rectangles instead. Anyone has any idea how can this be prevented from happening? Thanks.
ScriptableObject:
[CreateAssetMenu(fileName = "LevelRoster", menuName = "Picross/LevelRoster", order = 2)]
public class LevelRoster : ScriptableObject
{
[System.Serializable]
public class ChapterRoster
{
public Sprite chapterIcon;
public Sprite level1Icon;
public Sprite level2Icon;
public Sprite level3Icon;
public Sprite level4Icon;
public Sprite level5Icon;
}
public List<ChapterRoster> chapters;
public LevelRoster()
{
}
}
Editor:
[CustomEditor(typeof(LevelRoster))]
public class LevelRosterEditor : Editor
{
public override void OnInspectorGUI()
{
LevelRoster levels = (LevelRoster)target;
int index = 1;
foreach (LevelRoster.ChapterRoster chapter in levels.chapters)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.BeginHorizontal();
chapter.chapterIcon = this.addSpriteField(chapter.chapterIcon,"CH"+index+":");
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
chapter.level1Icon = this.addSpriteField(chapter.level1Icon,"1:");
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
chapter.level2Icon = this.addSpriteField(chapter.level2Icon,"2:");
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
chapter.level3Icon = this.addSpriteField(chapter.level3Icon,"3:");
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
chapter.level4Icon = this.addSpriteField(chapter.level4Icon,"4:");
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
chapter.level5Icon = this.addSpriteField(chapter.level5Icon,"5:");
EditorGUILayout.EndHorizontal();
EditorGUILayout.EndHorizontal();
index++;
}
if (GUI.changed)
EditorUtility.SetDirty(target);
}
private Sprite addSpriteField(Sprite sprite,string label)
{
EditorGUILayout.LabelField(label, GUILayout.Width(50));
return (Sprite)EditorGUILayout.ObjectField(GUIContent.none, sprite, typeof(Sprite), allowSceneObjects: false, options:GUILayout.Width(55));
}
}
flickering.png
(91.0 kB)
Comment
Answer by b1ackbird · Dec 05, 2019 at 04:17 PM
anyone solved this?
Fairly old thread, but it's not happening to me in 2019.3.3f1 DX11
Your answer
Follow this Question
Related Questions
Why does this keep happening? 0 Answers
Player Character glitching 0 Answers
Thin black lines between meshes 1 Answer
Unity editor - Keep columns narrow 0 Answers
Crash when reimporting custom assets 0 Answers