Skip to content

Instantly share code, notes, and snippets.

@mishazawa
Last active May 30, 2020 23:18
Show Gist options
  • Select an option

  • Save mishazawa/b08d98c18330e78bd563ae077976457f to your computer and use it in GitHub Desktop.

Select an option

Save mishazawa/b08d98c18330e78bd563ae077976457f to your computer and use it in GitHub Desktop.
[Unity] SpriteEditor bug on Linux
/*
Path to file
Unity/<Version>/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.2d.sprite/Editor/SpriteEditor/SpriteEditorMenu.cs
Issue:
https://issuetracker.unity3d.com/issues/linux-sprite-editor-slice-window-disappears-when-trying-to-change-slicing-type
*/
private void Init(Rect buttonRect, SpriteFrameModule sf, ITextureDataProvider dataProvider)
{
// ....................
// increase height of popup to see "Slice" button
float windowHeight = 295;
// ....................
}
private void OnGUI ()
{
// .....................................
SpriteEditorMenuSetting.SlicingType slicingType = s_Setting.slicingType;
EditorGUI.BeginChangeCheck();
Rect automatic = (Rect)EditorGUILayout.BeginVertical("Button");
if (GUI.Button(automatic, GUIContent.none)) slicingType = SpriteEditorMenuSetting.SlicingType.Automatic;
GUILayout.Label("Automatic");
EditorGUILayout.EndVertical();
Rect gridByCellSize = (Rect)EditorGUILayout.BeginVertical("Button");
if (GUI.Button(gridByCellSize, GUIContent.none)) slicingType = SpriteEditorMenuSetting.SlicingType.GridByCellSize;
GUILayout.Label("GridByCellSize");
EditorGUILayout.EndVertical();
Rect gridByCellCount = (Rect)EditorGUILayout.BeginVertical("Button");
if (GUI.Button(gridByCellCount, GUIContent.none)) slicingType = SpriteEditorMenuSetting.SlicingType.GridByCellCount;
GUILayout.Label("GridByCellCount");
EditorGUILayout.EndVertical();
// When open Enum Popup native GUI open dropdron list and Unity popup closing
// slicingType = (SpriteEditorMenuSetting.SlicingType)EditorGUILayout.EnumPopup(s_Styles.typeLabel, slicingType);
//
if (EditorGUI.EndChangeCheck()) {
Undo.RegisterCompleteObjectUndo(s_Setting, "Change slicing type");
s_Setting.slicingType = slicingType;
}
// ...........................
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment