using UnityEngine; using UnityEditor; using ShiroginSDK.Editor.Bitbucket; using ShiroginSDK.Runtime.Core.SDK; // Config için using ShiroginSDK.Runtime.Shared.Constants; namespace ShiroginSDK.Editor.Windows { [InitializeOnLoad] public class ShiroginWelcomeWindow : EditorWindow { private Texture2D _logo; // --- LINKS --- private const string DOCS_URL = "https://bitbucket.org/batud/shiroginsdk/src/Version_1/Assets/ShiroginSDK/README.md"; private const string CHANGELOG_URL = "https://bitbucket.org/batud/shiroginsdk/src/Version_1/Assets/ShiroginSDK/CHANGELOG.md"; private const string DISCORD_URL = "https://discord.gg/wgq3tc7h"; private const string WEBSITE_URL = "https://shirogin.com"; // --- PREFS --- private const string PREF_SHOW_AT_STARTUP = "ShiroginSDK_ShowWelcome_V2"; static ShiroginWelcomeWindow() { EditorApplication.delayCall += () => { if (EditorPrefs.GetBool(PREF_SHOW_AT_STARTUP, true)) { ShowWindow(); } }; } [MenuItem("ShiroginSDK/👋 Welcome", false, 0)] public static void ShowWindow() { // Pencere boyutunu biraz artırdım ki sığsın var window = GetWindow(true, "Welcome to Shirogin SDK", true); window.minSize = new Vector2(500, 520); window.maxSize = new Vector2(500, 520); window.Show(); } private void OnEnable() { string[] guids = AssetDatabase.FindAssets( "shirogin_logo t:Texture2D", new[] { "Assets/ShiroginSDK" } ); if (guids.Length > 0) { string path = AssetDatabase.GUIDToAssetPath(guids[0]); _logo = AssetDatabase.LoadAssetAtPath(path); } } private void OnGUI() { DrawBackground(); GUILayout.BeginVertical(); // 1. LOGO & BAŞLIK DrawHeader(); GUILayout.Space(15); // 2. HOŞGELDİN METNİ (Düzeltildi) DrawWelcomeMessage(); GUILayout.Space(20); // 3. BUTONLAR (Setup, Manager, Config) DrawActions(); GUILayout.FlexibleSpace(); // 4. ALT BİLGİ & LİNKLER DrawFooter(); GUILayout.EndVertical(); } private void DrawBackground() { EditorGUI.DrawRect(new Rect(0, 0, position.width, position.height), new Color(0.18f, 0.18f, 0.18f)); } private void DrawHeader() { GUILayout.Space(20); if (_logo != null) { var aspect = (float)_logo.width / _logo.height; var width = 120f; var height = width / aspect; var rect = GUILayoutUtility.GetRect(width, height); float xPos = (position.width - width) / 2; GUI.DrawTexture(new Rect(xPos, rect.y, width, height), _logo); } else { var titleStyle = new GUIStyle(EditorStyles.boldLabel) { fontSize = 28, alignment = TextAnchor.MiddleCenter, normal = { textColor = new Color(0.9f, 0.9f, 0.9f) } }; GUILayout.Label("SHIROGIN SDK", titleStyle); } var subStyle = new GUIStyle(EditorStyles.label) { fontSize = 12, alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Italic, normal = { textColor = new Color(0.6f, 0.6f, 0.6f) } }; // GUILayout.Label("Professional Unity Solutions", subStyle); } private void DrawWelcomeMessage() { var style = new GUIStyle(EditorStyles.label) { wordWrap = true, alignment = TextAnchor.MiddleCenter, fontSize = 14, richText = true, normal = { textColor = new Color(0.85f, 0.85f, 0.85f) } }; // GUILayout.Label kullanarak otomatik boyutlandırma sağladık GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // GUILayout.Label( // "Thank you for choosing ShiroginSDK.\n\n" + // "This toolkit provides everything you need to build scalable games,\n" + // "from Ads and IAP to Analytics and UI Frameworks.", // style, GUILayout.Width(420)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } private void DrawActions() { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // --- SETUP WIZARD --- if (DrawBigButton("🚀 Setup Wizard", "Install essential packages", new Color(0.2f, 0.6f, 0.3f))) { AssetRegistryEditor.ShowWindow(true); Close(); } GUILayout.Space(15); // --- ASSET MANAGER --- if (DrawBigButton("📦 Asset Manager", "Manage all modules", new Color(0.2f, 0.4f, 0.8f))) { AssetRegistryEditor.ShowWindow(false); Close(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(15); // --- OPEN CONFIG BUTTON (YENİ) --- GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); var configBtnStyle = new GUIStyle(GUI.skin.button) { fixedHeight = 35, fontSize = 12, fontStyle = FontStyle.Bold }; GUI.backgroundColor = new Color(0.9f, 0.6f, 0.2f); // Turuncu ton if (GUILayout.Button("⚙ Open SDK Config Settings", configBtnStyle, GUILayout.Width(250))) { SelectConfig(); Close(); } GUI.backgroundColor = Color.white; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } private bool DrawBigButton(string title, string subtitle, Color color) { var btnStyle = new GUIStyle(GUI.skin.button); var width = 200f; var height = 60f; var oldColor = GUI.backgroundColor; GUI.backgroundColor = color; bool clicked = GUILayout.Button("", btnStyle, GUILayout.Width(width), GUILayout.Height(height)); if (Event.current.type == EventType.Repaint) { var rect = GUILayoutUtility.GetLastRect(); var titleStyle = new GUIStyle(EditorStyles.boldLabel) { alignment = TextAnchor.MiddleCenter, fontSize = 15, normal = { textColor = Color.white } }; var subStyle = new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleCenter, fontSize = 10, normal = { textColor = new Color(1f, 1f, 1f, 0.85f) } }; // Pozisyonları biraz daha hassas ayarladım var titleRect = new Rect(rect.x, rect.y + 10, rect.width, 20); var subRect = new Rect(rect.x, rect.y + 32, rect.width, 20); GUI.Label(titleRect, title, titleStyle); GUI.Label(subRect, subtitle, subStyle); } GUI.backgroundColor = oldColor; return clicked; } private void DrawFooter() { GUILayout.BeginVertical(); // Çizgi var lineRect = GUILayoutUtility.GetRect(position.width - 40, 1); lineRect.x += 20; lineRect.width -= 40; EditorGUI.DrawRect(lineRect, new Color(0.3f, 0.3f, 0.3f)); GUILayout.Space(10); // Linkler GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (LinkButton("📚 Documentation", DOCS_URL)) { } GUILayout.Space(15); if (LinkButton("📚 Changelog", CHANGELOG_URL)) { } GUILayout.Space(15); if (LinkButton("💬 Discord", DISCORD_URL)) { } GUILayout.Space(15); if (LinkButton("🌐 Website", WEBSITE_URL)) { } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(10); // Toggle GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); bool show = EditorPrefs.GetBool(PREF_SHOW_AT_STARTUP, true); bool newShow = GUILayout.Toggle(show, "Show this window on startup"); if (newShow != show) EditorPrefs.SetBool(PREF_SHOW_AT_STARTUP, newShow); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.EndVertical(); } private bool LinkButton(string label, string url) { var style = new GUIStyle(EditorStyles.label) { normal = { textColor = new Color(0.4f, 0.7f, 1f) }, hover = { textColor = Color.white } }; if (GUILayout.Button(label, style, GUILayout.ExpandWidth(false))) { Application.OpenURL(url); return true; } return false; } // --- HELPER: CONFIG BULMA VE SEÇME --- private void SelectConfig() { var config = Resources.Load(SDKConstants.ConfigResourcePath); if (config != null) { Selection.activeObject = config; EditorGUIUtility.PingObject(config); Debug.Log("[ShiroginSDK] Config file selected."); } else { // Resources'da yoksa projede ara string[] guids = AssetDatabase.FindAssets("t:ShiroginConfig"); if (guids.Length > 0) { var path = AssetDatabase.GUIDToAssetPath(guids[0]); var obj = AssetDatabase.LoadAssetAtPath(path); Selection.activeObject = obj; EditorGUIUtility.PingObject(obj); } else { EditorUtility.DisplayDialog("Config Not Found", "ShiroginConfig file could not be found.\nPlease create it via 'Create > ShiroginSDK > ShiroginConfig'.", "OK"); } } } } }