Commit 4f3ab0f4 authored by Michael Schuh's avatar Michael Schuh
Browse files

first commit

parent 03edd9bf
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4272057970486951348
--- !u!1 &5982633111859369057
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
......@@ -8,46 +8,46 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8748265033449353036}
- component: {fileID: 4193247843755154056}
- component: {fileID: 1352882752130903487}
- component: {fileID: 1965405399831150563}
- component: {fileID: 5982633111859369062}
- component: {fileID: 5982633111859369061}
- component: {fileID: 5982633111859369060}
- component: {fileID: 5982633111859369063}
m_Layer: 0
m_Name: 2D
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8748265033449353036
--- !u!4 &5982633111859369062
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4272057970486951348}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.05, y: 0.05, z: 0.05}
m_GameObject: {fileID: 5982633111859369057}
m_LocalRotation: {x: 0.46193978, y: 0.19134173, z: 0.19134173, w: 0.84462327}
m_LocalPosition: {x: -0.0002, y: 0.0203, z: 0.0007}
m_LocalScale: {x: 0.02, y: 0.02, z: 0.02}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &4193247843755154056
m_LocalEulerAnglesHint: {x: 45, y: 45, z: 45}
--- !u!33 &5982633111859369061
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4272057970486951348}
m_GameObject: {fileID: 5982633111859369057}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &1352882752130903487
--- !u!23 &5982633111859369060
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4272057970486951348}
m_GameObject: {fileID: 5982633111859369057}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
......@@ -82,13 +82,13 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!65 &1965405399831150563
--- !u!65 &5982633111859369063
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4272057970486951348}
m_GameObject: {fileID: 5982633111859369057}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
......
fileFormatVersion: 2
guid: 57ee7db342bccc54e853d25117225f09
guid: 0675055ff7ac742f3a35fe36667670a4
PrefabImporter:
externalObjects: {}
userData:
......
fileFormatVersion: 2
guid: 833e12f1d550f2c4b96eb6fa3a5ea199
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 784c1ed2aa16453488a41efb0eeae8ce
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public class AddVuforiaEnginePackage
{
static readonly string sPackagesPath = Path.Combine(Application.dataPath, "..", "Packages");
static readonly string sManifestJsonPath = Path.Combine(sPackagesPath, "manifest.json");
const string VUFORIA_VERSION = "9.8.8";
const string PACKAGE_KEY = "com.ptc.vuforia.engine";
const string GIT_URL = "git+https://git-packages.developer.vuforia.com";
static readonly ScopedRegistry sVuforiaRegistry = new ScopedRegistry()
{
name = "Vuforia",
url = "https://registry.packages.developer.vuforia.com/",
scopes = new[] {"com.ptc.vuforia"}
};
static AddVuforiaEnginePackage()
{
if (Application.isBatchMode)
return;
var manifest = Manifest.JsonDeserialize(sManifestJsonPath);
if (!IsUsingRightGitUrl(manifest))
DisplayAddPackageDialogue(manifest);
}
static bool IsUsingRightGitUrl(Manifest manifest)
{
var dependencies = manifest.Dependencies.Split(',').ToList();
return dependencies.Any(d => d.Contains(PACKAGE_KEY) && d.Contains(GIT_URL) && VersionNumberIsTheLatest(d));
}
static bool VersionNumberIsTheLatest(string package)
{
var version = package.Split('#');
if (version.Length >= 2)
{
version[1] = version[1].TrimEnd(new []{ '"' });
return IsCurrentVersionHigher(version[1]);
}
return false;
}
static bool IsCurrentVersionHigher(string currentVersionString)
{
if (string.IsNullOrEmpty(currentVersionString) || string.IsNullOrEmpty(VUFORIA_VERSION))
return false;
var currentVersion = TryConvertStringToVersion(currentVersionString);
var updatingVersion = TryConvertStringToVersion(VUFORIA_VERSION);
if (currentVersion >= updatingVersion)
return true;
return false;
}
static Version TryConvertStringToVersion(string versionString)
{
Version res;
try
{
res = new Version(versionString);
}
catch (Exception e)
{
return new Version();
}
return new Version(res.Major, res.Minor, res.Build);
}
static void DisplayAddPackageDialogue(Manifest manifest)
{
if (EditorUtility.DisplayDialog("Add Vuforia Engine Package",
$"Would you like to update your project to include the Vuforia Engine {VUFORIA_VERSION} package from Git?\n" +
$"If an older Vuforia Engine package is already present in your project it will be upgraded to version {VUFORIA_VERSION}\n\n" +
$"Please make sure that Git is installed and on your PATH environment variable.", "Update", "Cancel"))
{
UpdateManifest(manifest);
}
}
static void UpdateManifest(Manifest manifest)
{
//remove existing, outdated NPM scoped registry if present
var registries = manifest.ScopedRegistries.ToList();
if (registries.Contains(sVuforiaRegistry))
{
registries.Remove(sVuforiaRegistry);
manifest.ScopedRegistries = registries.ToArray();
}
//add specified vuforia version via Git URL
SetVuforiaVersion(manifest);
manifest.JsonSerialize(sManifestJsonPath);
AssetDatabase.Refresh();
}
static void SetVuforiaVersion(Manifest manifest)
{
var dependencies = manifest.Dependencies.Split(',').ToList();
var versionEntry = $"\"{GIT_URL}#{VUFORIA_VERSION}\"";
var versionSet = false;
for (var i = 0; i < dependencies.Count; i++)
{
if (!dependencies[i].Contains(PACKAGE_KEY))
continue;
var kvp = dependencies[i].Split(':');
dependencies[i] = kvp[0] + ": " + versionEntry;
versionSet = true;
}
if (!versionSet)
dependencies.Insert(0, $"\n \"{PACKAGE_KEY}\": {versionEntry}");
manifest.Dependencies = string.Join(",", dependencies);
}
class Manifest
{
const int INDEX_NOT_FOUND = -1;
const string DEPENDENCIES_KEY = "\"dependencies\"";
public ScopedRegistry[] ScopedRegistries;
public string Dependencies;
public void JsonSerialize(string path)
{
var jsonString = GetJsonString();
var startIndex = GetDependenciesStart(jsonString);
var endIndex = GetDependenciesEnd(jsonString, startIndex);
var stringBuilder = new StringBuilder();
stringBuilder.Append(jsonString.Substring(0, startIndex));
stringBuilder.Append(Dependencies);
stringBuilder.Append(jsonString.Substring(endIndex, jsonString.Length - endIndex));
File.WriteAllText(path, stringBuilder.ToString());
}
string GetJsonString()
{
if (ScopedRegistries.Length > 0)
return JsonUtility.ToJson(
new UnitySerializableManifest {scopedRegistries = ScopedRegistries, dependencies = new DependencyPlaceholder()},
true);
return JsonUtility.ToJson(
new UnitySerializableManifestDependenciesOnly() {dependencies = new DependencyPlaceholder()},
true);
}
public static Manifest JsonDeserialize(string path)
{
var jsonString = File.ReadAllText(path);
var registries = JsonUtility.FromJson<UnitySerializableManifest>(jsonString).scopedRegistries ?? new ScopedRegistry[0];
var dependencies = DeserializeDependencies(jsonString);
return new Manifest {ScopedRegistries = registries, Dependencies = dependencies};
}
static string DeserializeDependencies(string json)
{
var startIndex = GetDependenciesStart(json);
var endIndex = GetDependenciesEnd(json, startIndex);
if (startIndex == INDEX_NOT_FOUND || endIndex == INDEX_NOT_FOUND)
return null;
var dependencies = json.Substring(startIndex, endIndex - startIndex);
return dependencies;
}
static int GetDependenciesStart(string json)
{
var dependenciesIndex = json.IndexOf(DEPENDENCIES_KEY, StringComparison.InvariantCulture);
if (dependenciesIndex == INDEX_NOT_FOUND)
return INDEX_NOT_FOUND;
var dependenciesStartIndex = json.IndexOf('{', dependenciesIndex + DEPENDENCIES_KEY.Length);
if (dependenciesStartIndex == INDEX_NOT_FOUND)
return INDEX_NOT_FOUND;
dependenciesStartIndex++; //add length of '{' to starting point
return dependenciesStartIndex;
}
static int GetDependenciesEnd(string jsonString, int dependenciesStartIndex)
{
return jsonString.IndexOf('}', dependenciesStartIndex);
}
}
class UnitySerializableManifestDependenciesOnly
{
public DependencyPlaceholder dependencies;
}
class UnitySerializableManifest
{
public ScopedRegistry[] scopedRegistries;
public DependencyPlaceholder dependencies;
}
[Serializable]
struct ScopedRegistry
{
public string name;
public string url;
public string[] scopes;
public override bool Equals(object obj)
{
if (!(obj is ScopedRegistry))
return false;
var other = (ScopedRegistry) obj;
return name == other.name &&
url == other.url &&
scopes.SequenceEqual(other.scopes);
}
public static bool operator ==(ScopedRegistry a, ScopedRegistry b)
{
return a.Equals(b);
}
public static bool operator !=(ScopedRegistry a, ScopedRegistry b)
{
return !a.Equals(b);
}
public override int GetHashCode()
{
var hash = 17;
foreach (var scope in scopes)
hash = hash * 23 + (scope == null ? 0 : scope.GetHashCode());
hash = hash * 23 + (name == null ? 0 : name.GetHashCode());
hash = hash * 23 + (url == null ? 0 : url.GetHashCode());
return hash;
}
}
[Serializable]
struct DependencyPlaceholder { }
}
\ No newline at end of file
fileFormatVersion: 2
guid: 3bbef22eb814a9647b6c1f03e99d95da
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
{
"name": "EditorMigrationScripts",
"references": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
}
\ No newline at end of file
fileFormatVersion: 2
guid: f3a385ed4c943d742a2e7a85a3d4386d
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 41d3df85bf227403ba8a59b650d64514
guid: e2ebd3229695f904ca6aec0bf9136be5
folderAsset: yes
DefaultImporter:
externalObjects: {}
......
fileFormatVersion: 2
guid: 8f988c2ebbccd4f1cad55845067ea92a
guid: 9a835b197ef6b5b26a1536eecbfb6b10
folderAsset: yes
DefaultImporter:
externalObjects: {}
......
fileFormatVersion: 2
guid: 35fbef93cdbca29ceb9543d3bfa4bc98
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 8e84da03d6cd6d137912bc76e85536d1
guid: 8e420b5f1cf94adca921e49bf5ee1974
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
......@@ -61,14 +61,14 @@ TextureImporter:
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
applyGammaDecoding: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
......@@ -76,11 +76,11 @@ TextureImporter:
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
......@@ -88,15 +88,39 @@ TextureImporter:
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Lumin
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: 34
textureCompression: 1
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Windows Store Apps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
......
fileFormatVersion: 2
guid: ef80b6c9054fd41efb464b70cd306ecb
guid: a542312610044cbcbcf7fd6b74330e75
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
......@@ -32,16 +32,16 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
......@@ -50,23 +50,25 @@ TextureImporter:
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 8
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
applyGammaDecoding: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
......@@ -74,11 +76,11 @@ TextureImporter:
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0