// /*=============================================================================== // Copyright (C) 2020 PhantomsXR Ltd. All Rights Reserved. // // This file is part of the AR-MOD SDK. // // The AR-MOD SDK cannot be copied, distributed, or made available to // third-parties for commercial purposes without written permission of PhantomsXR Ltd. // // Contact info@phantomsxr.com for licensing requests. // ===============================================================================*/ using System; using System.Collections; using System.Collections.Generic; using System.IO; using Newtonsoft.Json; using UnityEditor; using UnityEngine; using UnityEngine.UIElements; using UnityEngine.Assertions; using UnityEngine.Networking; using Button = UnityEngine.UIElements.Button; namespace Phantom.XRMOD.XRMODPackageTools.Editor { public class NewProjectWizard : EditorWindow { private const string CONST_SAVE_FILE_PANEL_TITLE = "New Project Wizard"; private const string CONST_ROOT_PATH = "Assets"; private const string CONST_STYLES = "NewProjectWizard"; internal const string CONST_TEMPLATE_DATA_URL = "https://raw.githubusercontent.com/PhantomsXR/XRMODProjectTemplates/refs/heads/main/TemplateData.json"; private static string NEW_PROJECT_PATH; private static string NEW_PROJECT_NAME; private TemplateDataModel selectedTemplateData; private List templateList = new List(); //[MenuItem("Tools/AR-MOD/Create New Project")] public static void ShowNewProjectWizard() { var tmp_Wnd = GetWindow(true, "New Project Wizard", true); tmp_Wnd.maxSize = new Vector2(600, 450); tmp_Wnd.minSize = new Vector2(600, 450); tmp_Wnd.ShowUtility(); } public void CreateGUI() { templateList.Clear(); TestRequestTemplateData(); VisualElement tmp_Root = rootVisualElement; var tmp_VisualTree = AssetDatabase.LoadAssetAtPath($"{ConstKey.CONST_UASSETS_PATH}/{CONST_STYLES}.uxml"); if (!tmp_VisualTree) return; tmp_VisualTree.CloneTree(tmp_Root); var tmp_StyleSheet = AssetDatabase.LoadAssetAtPath($"{ConstKey.CONST_UASSETS_PATH}/{CONST_STYLES}.uss"); tmp_Root.styleSheets.Add(tmp_StyleSheet); var tmp_ProjectNameInputer = tmp_Root.Q("project-inputer"); tmp_ProjectNameInputer.RegisterCallback>(_evt => { if (!Utility.IsValidClassName(_evt.newValue) || !Utility.IsValidProject(_evt.newValue)) { tmp_ProjectNameInputer.AddToClassList("project-validation"); tmp_Root.Q