Moves demo to Examples folder

This commit is contained in:
Momo The Monster
2023-08-28 17:53:31 -07:00
parent 8e4c15b320
commit ac58660cc4
84 changed files with 1623 additions and 101 deletions

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: ec897c206a99abe41b093d5cc5ddc3fe
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -3,14 +3,13 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEditor.VersionControl;
using UnityEngine;
using UnityEngine.UIElements;
using VRC.PackageManagement.Core.Types.Packages;
using YamlDotNet.Serialization.NodeTypeResolvers;
namespace VRC.PackageManagement.PackageMaker
{
@@ -22,6 +21,9 @@ namespace VRC.PackageManagement.PackageMaker
private TextField _packageIDField;
private Button _actionButton;
private EnumField _targetVRCPackageField;
private TextField _authorNameField;
private TextField _authorEmailField;
private TextField _authorUrlField;
private static string _projectDir;
private PackageMakerWindowData _windowData;
@@ -33,6 +35,9 @@ namespace VRC.PackageManagement.PackageMaker
}
_packageIDField.SetValueWithoutNotify(_windowData.packageID);
_targetVRCPackageField.SetValueWithoutNotify(_windowData.relatedPackage);
_authorEmailField.SetValueWithoutNotify(_windowData.authorEmail);
_authorNameField.SetValueWithoutNotify(_windowData.authorName);
_authorUrlField.SetValueWithoutNotify(_windowData.authorUrl);
RefreshActionButtonState();
}
@@ -53,27 +58,30 @@ namespace VRC.PackageManagement.PackageMaker
[MenuItem("Assets/Export VPM as UnityPackage")]
private static void ExportAsUnityPackage ()
{
if (Selection.assetGUIDs.Length != 1)
var foldersToExport = new List<string>();
StringBuilder exportFilename = new StringBuilder("exported");
foreach (string guid in Selection.assetGUIDs)
{
Debug.LogWarning($"Cannot export selection, must be a single Folder.");
return;
}
string selectedFolder = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
var manifestPath = Path.Combine(selectedFolder, VRCPackageManifest.Filename);
var manifest = VRCPackageManifest.GetManifestAtPath(manifestPath);
if (manifest == null)
{
Debug.LogWarning($"Could not read valid Package Manifest at {manifestPath}. You need to create this first.");
return;
string selectedFolder = AssetDatabase.GUIDToAssetPath(guid);
var manifestPath = Path.Combine(selectedFolder, VRCPackageManifest.Filename);
var manifest = VRCPackageManifest.GetManifestAtPath(manifestPath);
if (manifest == null)
{
Debug.LogWarning($"Could not read valid Package Manifest at {manifestPath}. You need to create this first to export a VPM Package.");
continue;
}
exportFilename.Append($"-{manifest.Id}-{manifest.Version}");
foldersToExport.Add(selectedFolder);
}
exportFilename.Append(".unitypackage");
var exportDir = Path.Combine(Directory.GetCurrentDirectory(), "Exports");
Directory.CreateDirectory(exportDir);
AssetDatabase.ExportPackage
(
selectedFolder,
Path.Combine(exportDir, $"{manifest.Id}-{manifest.Version}.unitypackage"),
foldersToExport.ToArray(),
Path.Combine(exportDir, exportFilename.ToString()),
ExportPackageOptions.Recurse | ExportPackageOptions.Interactive
);
}
@@ -97,7 +105,9 @@ namespace VRC.PackageManagement.PackageMaker
{
_actionButton.SetEnabled(
StringIsValidAssetFolder(_windowData.targetAssetFolder) &&
!string.IsNullOrWhiteSpace(_windowData.packageID)
!string.IsNullOrWhiteSpace(_windowData.packageID) &&
_authorNameField.value != null &&
IsValidEmail(_authorEmailField.value)
);
}
@@ -118,6 +128,7 @@ namespace VRC.PackageManagement.PackageMaker
// Create Target Asset folder and register for drag and drop events
_rootView.Add(CreateTargetFolderElement());
_rootView.Add(CreatePackageIDElement());
_rootView.Add(CreateAuthorElement());
_rootView.Add(CreateTargetVRCPackageElement());
_rootView.Add(CreateActionButton());
@@ -202,6 +213,59 @@ namespace VRC.PackageManagement.PackageMaker
return box;
}
private VisualElement CreateAuthorElement()
{
// Construct author fields
_authorNameField = new TextField("Author Name");
_authorEmailField = new TextField("Author Email");
_authorUrlField = new TextField("Author URL (optional)");
// Save name to window data and toggle the Action Button if its status changed
_authorNameField.RegisterValueChangedCallback((evt) =>
{
_windowData.authorName = evt.newValue;
Debug.Log($"Window author name is {evt.newValue}");
RefreshActionButtonState();
});
// Save email to window data if valid and toggle the Action Button if its status changed
_authorEmailField.RegisterValueChangedCallback((evt) =>
{
// Only save email if it appears valid
if (IsValidEmail(evt.newValue))
{
_windowData.authorEmail = evt.newValue;
}
RefreshActionButtonState();
});
// Save url to window data, doesn't affect action button state
_authorUrlField.RegisterValueChangedCallback((evt) =>
{
_windowData.authorUrl = evt.newValue;
});
// Add new fields to layout
var box = new Box();
box.Add(_authorNameField);
box.Add(_authorEmailField);
box.Add(_authorUrlField);
return box;
}
private bool IsValidEmail(string evtNewValue)
{
try
{
var addr = new System.Net.Mail.MailAddress(evtNewValue);
return addr.Address == evtNewValue;
}
catch
{
return false;
}
}
private Regex packageIdRegex = new Regex("[^a-z0-9.]");
private void OnPackageIDChanged(ChangeEvent<string> evt)
{
@@ -331,13 +395,26 @@ namespace VRC.PackageManagement.PackageMaker
}
string parentDir = new DirectoryInfo(targetDir)?.Parent.FullName;
Core.Utilities.CreateStarterPackage(_windowData.packageID, parentDir, packageType);
var packageDir = Core.Utilities.CreateStarterPackage(_windowData.packageID, parentDir, packageType);
// Modify manifest to add author
// Todo: add support for passing author into CreateStarterPackage
var manifest =
VRCPackageManifest.GetManifestAtPath(Path.Combine(packageDir, VRCPackageManifest.Filename)) as
VRCPackageManifest;
manifest.author = new Author()
{
email = _windowData.authorEmail,
name = _windowData.authorName,
url = _windowData.authorUrl
};
manifest.Save();
var allFiles = GetAllFiles(corePath).ToList();
MoveFilesToPackageDir(allFiles, corePath, targetDir);
// Clear target asset folder since it should no longer exist
_windowData.targetAssetFolder = "";
}
private static IEnumerable<string> GetAllFiles(string path)

View File

@@ -8,6 +8,10 @@ public class PackageMakerWindowData : ScriptableObject
public static string defaultAssetPath = Path.Combine("Assets", "PackageMakerWindowData.asset");
public string targetAssetFolder;
public string packageID;
public string authorName;
public string authorEmail;
public string authorUrl;
public PackageMakerWindow.VRCPackageEnum relatedPackage;
public static PackageMakerWindowData GetOrCreate()

View File

@@ -11,6 +11,7 @@ using UnityEngine;
using VRC.PackageManagement.Core;
using VRC.PackageManagement.Core.Types;
using VRC.PackageManagement.Core.Types.Packages;
using Version = VRC.PackageManagement.Core.Types.VPMVersion.Version;
namespace VRC.PackageManagement.Resolver
{

View File

@@ -1,10 +1,10 @@
{
"name" : "com.vrchat.core.vpm-resolver",
"displayName" : "VRChat Package Resolver Tool",
"version" : "0.1.17",
"version" : "0.1.21",
"unity" : "2019.4",
"description" : "Tool to Download VPM Packages",
"vrchatVersion" : "2022.1.1",
"vrchatVersion" : "2022.2.2",
"author" : {
"name" : "VRChat",
"email" : "developer@vrchat.com",
@@ -12,6 +12,6 @@
},
"url" : "",
"dependencies" : {
"com.unity.nuget.newtonsoft-json" : "2.0.2"
"com.unity.nuget.newtonsoft-json" : "3.0.2"
}
}

View File

@@ -55,15 +55,6 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.inputsystem": {
"version": "1.2.0",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.modules.uielements": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.mathematics": {
"version": "1.2.5",
"depth": 1,
@@ -72,7 +63,7 @@
"url": "https://packages.unity.com"
},
"com.unity.nuget.newtonsoft-json": {
"version": "2.0.2",
"version": "3.0.2",
"depth": 1,
"source": "registry",
"dependencies": {},
@@ -149,16 +140,7 @@
"dependencies": {
"com.unity.burst": "1.4.11",
"com.unity.mathematics": "1.2.5",
"com.unity.nuget.newtonsoft-json": "2.0.2"
}
},
"com.vrchat.clientsim": {
"version": "file:com.vrchat.clientsim",
"depth": 0,
"source": "embedded",
"dependencies": {
"com.unity.xr.oculus.standalone": "2.38.4",
"com.unity.inputsystem": "1.2.0"
"com.unity.nuget.newtonsoft-json": "3.0.2"
}
},
"com.vrchat.core.vpm-resolver": {

View File

@@ -18,13 +18,13 @@
}
},
"com.vrchat.worlds": {
"version": "3.1.11",
"version": "3.2.3",
"dependencies": {
"com.vrchat.base": "3.1.11"
"com.vrchat.base": "3.2.3"
}
},
"com.vrchat.base": {
"version": "3.1.11",
"version": "3.2.3",
"dependencies": {}
},
"com.vrchat.clientsim": {
@@ -34,7 +34,7 @@
}
},
"com.vrchat.core.vpm-resolver": {
"version": "0.1.17",
"version": "0.1.21",
"dependencies": {}
}
}