From 8722a9920c1f6119bf6e769cba270e63097f8e25 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Thu, 23 May 2024 10:08:29 +0800 Subject: + astar project --- .../Editor/UI/WelcomeScreen.cs | 200 +++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Editor/UI/WelcomeScreen.cs (limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Editor/UI/WelcomeScreen.cs') diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Editor/UI/WelcomeScreen.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Editor/UI/WelcomeScreen.cs new file mode 100644 index 0000000..424dad2 --- /dev/null +++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Editor/UI/WelcomeScreen.cs @@ -0,0 +1,200 @@ +using System; +using System.Linq; +using UnityEditor; +using UnityEditor.SceneManagement; +using UnityEditor.UIElements; +using UnityEngine; +using UnityEngine.UIElements; +using UnityEditor.Compilation; +using UnityEditor.Scripting.ScriptCompilation; + +namespace Pathfinding { + internal class WelcomeScreen : UnityEditor.EditorWindow { + [SerializeField] + private VisualTreeAsset m_VisualTreeAsset = default; + + public bool isImportingSamples; + private bool askedAboutQuitting; + + [InitializeOnLoadMethod] + public static void TryCreate () { + if (!PathfindingEditorSettings.instance.hasShownWelcomeScreen) { + // Wait a bit before showing the window to avoid stuttering + // as all the other windows in Unity load. + // This makes the animation smoother. + var delay = 0.5f; + var t0 = Time.realtimeSinceStartup; + EditorApplication.CallbackFunction create = null; + create = () => { + if (Time.realtimeSinceStartup - t0 > delay) { + EditorApplication.update -= create; + PathfindingEditorSettings.instance.hasShownWelcomeScreen = true; + PathfindingEditorSettings.instance.Save(); + Create(); + } + }; + EditorApplication.update += create; + } + } + + public static void Create () { + var window = GetWindow( + true, + "A* Pathfinding Project", + true + ); + window.minSize = window.maxSize = new Vector2(400, 400*1.618f); + window.ShowUtility(); + } + + + public void CreateGUI () { + VisualElement root = rootVisualElement; + + VisualElement labelFromUXML = m_VisualTreeAsset.Instantiate(); + root.Add(labelFromUXML); + + var sampleButton = root.Query