Skip to content

Instantly share code, notes, and snippets.

@mikenekoworks
Last active February 14, 2017 03:20
Show Gist options
  • Save mikenekoworks/9e52bce9903dde5be8d067e30cc6563f to your computer and use it in GitHub Desktop.
Save mikenekoworks/9e52bce9903dde5be8d067e30cc6563f to your computer and use it in GitHub Desktop.
GridPaletteUtilityを使ってPaletteWindowにPaletteを新規追加する。
var type = System.Reflection.Assembly.Load( "UnityEditor.dll" ).GetType( "UnityEditor.GridPaletteUtility" );
var method_info = type.GetMethods (System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public );
System.Reflection.MethodInfo find_method = null;
foreach (var method in method_info) {
if ( ( method.Name == "CreateNewPalette" ) && ( method.GetParameters().Length == 2 ) ) {
find_method = method;
break;
}
}
if (find_method != null) {
GameObject go = (GameObject)find_method.Invoke (null, new object[] { "Assets/NewPalette1.prefab", Grid.CellLayout.Rectangle });
Debug.Log ( go );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment