Skip to content

Instantly share code, notes, and snippets.

@baba-s
Created March 22, 2024 01:48
Show Gist options
  • Save baba-s/338bd0a5955a81430f70181925b8ad4d to your computer and use it in GitHub Desktop.
Save baba-s/338bd0a5955a81430f70181925b8ad4d to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
namespace Kogane.Internal
{
internal sealed class MergedAndroidManifestPathWindow : EditorWindow
{
private Vector2 m_scrollPosition;
[MenuItem( "Window/Kogane/Merged Android Manifest Path", false, 1425221149 )]
private static void Open()
{
GetWindow<MergedAndroidManifestPathWindow>( "Merged Android Manifest Path" );
}
private void OnGUI()
{
using var scope = new EditorGUILayout.ScrollViewScope( m_scrollPosition );
var drawer = new Drawer( 120 );
drawer.Draw( "IL2CPP + Debug", "Library/Bee/Android/Prj/IL2CPP/Gradle/launcher/build/intermediates/merged_manifest/debug/AndroidManifest.xml" );
drawer.Draw( "IL2CPP + Release", "Library/Bee/Android/Prj/IL2CPP/Gradle/launcher/build/intermediates/merged_manifest/release/AndroidManifest.xml" );
drawer.Draw( "Mono2x + Debug", "Library/Bee/Android/Prj/Mono2x/Gradle/launcher/build/intermediates/merged_manifest/debug/AndroidManifest.xml" );
drawer.Draw( "Mono2x + Release", "Library/Bee/Android/Prj/Mono2x/Gradle/launcher/build/intermediates/merged_manifest/release/AndroidManifest.xml" );
m_scrollPosition = scope.scrollPosition;
}
private readonly struct Drawer
{
private readonly int m_width;
public Drawer( int width ) => m_width = width;
public void Draw( string label, string path )
{
using var horizontalScope = new EditorGUILayout.HorizontalScope();
EditorGUILayout.LabelField( label, GUILayout.Width( m_width ) );
if ( GUILayout.Button( "Copy", GUILayout.Width( 40 ) ) )
{
EditorGUIUtility.systemCopyBuffer = path;
}
var directoryName = Path.GetDirectoryName( path ).Replace( "\\", "/" );
var isExistDirectory = Directory.Exists( directoryName );
GUI.enabled = isExistDirectory;
if ( GUILayout.Button( "Open Directory", GUILayout.Width( 100 ) ) )
{
try
{
System.Diagnostics.Process.Start( directoryName );
}
catch ( Exception e )
{
Debug.LogError( e.Message );
}
}
var isExistFile = File.Exists( path );
GUI.enabled = isExistFile;
if ( GUILayout.Button( "Open File", GUILayout.Width( 80 ) ) )
{
try
{
System.Diagnostics.Process.Start( path );
}
catch ( Exception e )
{
Debug.LogError( e.Message );
}
}
GUI.enabled = true;
EditorGUILayout.TextField( path );
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment