Added Unity project files
This commit is contained in:
@ -0,0 +1,213 @@
|
||||
#if false
|
||||
-----------------------------------------------------------------------
|
||||
<copyright file="GlobalSerializationConfig.cs" company="Sirenix IVS">
|
||||
Copyright (c) 2018 Sirenix IVS
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
</copyright>
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
namespace VRC.Udon.Serialization.OdinSerializer.Utilities.Editor
|
||||
{
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
|
||||
public enum AssemblyImportSettings
|
||||
{
|
||||
BuildOnly,
|
||||
EditorOnly,
|
||||
BuildAndEditor,
|
||||
Exclude,
|
||||
}
|
||||
|
||||
public static class OdinSerializationBuiltSettingsConfig
|
||||
{
|
||||
public static readonly OdinSerializationBuiltSettings AOT = new AOTImportSettingsConfig();
|
||||
public static readonly OdinSerializationBuiltSettings JIT = new JITImportSettingsConfig();
|
||||
public static readonly OdinSerializationBuiltSettings EditorOnly = new EditorOnlyImportSettingsConfig();
|
||||
|
||||
public static OdinSerializationBuiltSettings Current
|
||||
{
|
||||
get
|
||||
{
|
||||
var buildGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
NamedBuildTarget namedBuildTarget = NamedBuildTarget.FromBuildTargetGroup(buildGroup);
|
||||
var backend = PlayerSettings.GetScriptingBackend(namedBuildTarget);
|
||||
#elif UNITY_5_6_OR_NEWER
|
||||
var backend = PlayerSettings.GetScriptingBackend(buildGroup);
|
||||
#else
|
||||
var backend = (ScriptingImplementation)PlayerSettings.GetPropertyInt("ScriptingBackend", buildGroup);
|
||||
#endif
|
||||
|
||||
if (backend != ScriptingImplementation.Mono2x)
|
||||
{
|
||||
return AOT;
|
||||
}
|
||||
|
||||
var target = EditorUserBuildSettings.activeBuildTarget;
|
||||
|
||||
if (OdinAssemblyImportSettingsUtility.JITPlatforms.Any(p => p == target))
|
||||
{
|
||||
return JIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
return AOT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Odin Serializer/Refresh Assembly Import Settings")]
|
||||
public static void RefreshAssemblyImportSettings()
|
||||
{
|
||||
Current.Apply();
|
||||
}
|
||||
}
|
||||
|
||||
public static class OdinAssemblyImportSettingsUtility
|
||||
{
|
||||
public static readonly BuildTarget[] Platforms = Enum.GetValues(typeof(BuildTarget))
|
||||
.Cast<BuildTarget>()
|
||||
.Where(t => t >= 0 && typeof(BuildTarget).GetMember(t.ToString())[0].IsDefined(typeof(ObsoleteAttribute), false) == false)
|
||||
.ToArray();
|
||||
|
||||
public static readonly BuildTarget[] JITPlatforms = new BuildTarget[]
|
||||
{
|
||||
BuildTarget.StandaloneOSX,
|
||||
BuildTarget.StandaloneWindows,
|
||||
BuildTarget.StandaloneWindows64,
|
||||
BuildTarget.StandaloneLinux64,
|
||||
BuildTarget.Android,
|
||||
};
|
||||
|
||||
public static void ApplyImportSettings(string assemblyFilePath, AssemblyImportSettings importSettings)
|
||||
{
|
||||
bool includeInBuild = false;
|
||||
bool includeInEditor = false;
|
||||
|
||||
switch (importSettings)
|
||||
{
|
||||
case AssemblyImportSettings.BuildAndEditor:
|
||||
includeInBuild = true;
|
||||
includeInEditor = true;
|
||||
break;
|
||||
|
||||
case AssemblyImportSettings.BuildOnly:
|
||||
includeInBuild = true;
|
||||
break;
|
||||
|
||||
case AssemblyImportSettings.EditorOnly:
|
||||
includeInEditor = true;
|
||||
break;
|
||||
|
||||
case AssemblyImportSettings.Exclude:
|
||||
break;
|
||||
}
|
||||
|
||||
ApplyImportSettings(assemblyFilePath, includeInBuild, includeInEditor);
|
||||
}
|
||||
|
||||
private static void ApplyImportSettings(string assemblyFilePath, bool includeInBuild, bool includeInEditor)
|
||||
{
|
||||
var importer = (PluginImporter)AssetImporter.GetAtPath(assemblyFilePath);
|
||||
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
if (importer.GetCompatibleWithAnyPlatform() != includeInBuild
|
||||
|| Platforms.Any(p => importer.GetCompatibleWithPlatform(p) != includeInBuild)
|
||||
|| (includeInBuild && importer.GetExcludeEditorFromAnyPlatform() != !includeInEditor || importer.GetCompatibleWithEditor()))
|
||||
{
|
||||
importer.ClearSettings();
|
||||
importer.SetCompatibleWithAnyPlatform(includeInBuild);
|
||||
Array.ForEach(Platforms,p => importer.SetCompatibleWithPlatform(p, includeInBuild));
|
||||
|
||||
if (includeInBuild)
|
||||
{
|
||||
importer.SetExcludeEditorFromAnyPlatform(!includeInEditor);
|
||||
}
|
||||
else
|
||||
{
|
||||
importer.SetCompatibleWithEditor(includeInEditor);
|
||||
}
|
||||
|
||||
importer.SaveAndReimport();
|
||||
}
|
||||
#else
|
||||
if (importer.GetCompatibleWithAnyPlatform() != includeInBuild
|
||||
|| Platforms.Any(p => importer.GetCompatibleWithPlatform(p) != includeInBuild)
|
||||
|| importer.GetCompatibleWithEditor() != includeInEditor)
|
||||
{
|
||||
importer.SetCompatibleWithAnyPlatform(includeInBuild);
|
||||
Platforms.ForEach(p => importer.SetCompatibleWithPlatform(p, includeInBuild));
|
||||
importer.SetCompatibleWithEditor(includeInEditor);
|
||||
|
||||
importer.SaveAndReimport();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class OdinSerializationBuiltSettings
|
||||
{
|
||||
protected const string NoEditorSerializationMeta = "Assets/Plugins/Sirenix/Assemblies/NoEditor/Sirenix.Serialization.dll";
|
||||
protected const string NoEditorUtilityMeta = "Assets/Plugins/Sirenix/Assemblies/NoEditor/Sirenix.Utilities.dll";
|
||||
protected const string NoEmitNoEditorSerializationMeta = "Assets/Plugins/Sirenix/Assemblies/NoEmitAndNoEditor/Sirenix.Serialization.dll";
|
||||
protected const string NoEmitNoEditorUtilityMeta = "Assets/Plugins/Sirenix/Assemblies/NoEmitAndNoEditor/Sirenix.Utilities.dll";
|
||||
protected const string SerializationConfigMeta = "Assets/Plugins/Sirenix/Assemblies/Sirenix.Serialization.Config.dll";
|
||||
|
||||
public abstract void Apply();
|
||||
}
|
||||
|
||||
public class AOTImportSettingsConfig : OdinSerializationBuiltSettings
|
||||
{
|
||||
public override void Apply()
|
||||
{
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(NoEmitNoEditorSerializationMeta, AssemblyImportSettings.BuildOnly);
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(NoEmitNoEditorUtilityMeta, AssemblyImportSettings.BuildOnly);
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(NoEditorSerializationMeta, AssemblyImportSettings.Exclude);
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(NoEditorUtilityMeta, AssemblyImportSettings.Exclude);
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(SerializationConfigMeta, AssemblyImportSettings.BuildAndEditor);
|
||||
}
|
||||
}
|
||||
|
||||
public class JITImportSettingsConfig : OdinSerializationBuiltSettings
|
||||
{
|
||||
public override void Apply()
|
||||
{
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(NoEditorSerializationMeta, AssemblyImportSettings.BuildOnly);
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(NoEditorUtilityMeta, AssemblyImportSettings.BuildOnly);
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(NoEmitNoEditorSerializationMeta, AssemblyImportSettings.Exclude);
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(NoEmitNoEditorUtilityMeta, AssemblyImportSettings.Exclude);
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(SerializationConfigMeta, AssemblyImportSettings.BuildAndEditor);
|
||||
}
|
||||
}
|
||||
|
||||
public class EditorOnlyImportSettingsConfig : OdinSerializationBuiltSettings
|
||||
{
|
||||
public override void Apply()
|
||||
{
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(NoEditorSerializationMeta, AssemblyImportSettings.Exclude);
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(NoEditorUtilityMeta, AssemblyImportSettings.Exclude);
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(NoEmitNoEditorSerializationMeta, AssemblyImportSettings.Exclude);
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(NoEmitNoEditorUtilityMeta, AssemblyImportSettings.Exclude);
|
||||
OdinAssemblyImportSettingsUtility.ApplyImportSettings(SerializationConfigMeta, AssemblyImportSettings.EditorOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c57d4a1577bbb34c88b7a1190c26097
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,74 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="GlobalSerializationConfig.cs" company="Sirenix IVS">
|
||||
// Copyright (c) 2018 Sirenix IVS
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace VRC.Udon.Serialization.OdinSerializer
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains global configuration options for the serialization system.
|
||||
/// </summary>
|
||||
public class GlobalSerializationConfig
|
||||
{
|
||||
private static readonly GlobalSerializationConfig instance = new GlobalSerializationConfig();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the global configuration instance.
|
||||
/// </summary>
|
||||
public static GlobalSerializationConfig Instance { get { return GlobalSerializationConfig.instance; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the logger.
|
||||
/// </summary>
|
||||
public ILogger Logger { get { return DefaultLoggers.UnityLogger; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the editor serialization format.
|
||||
/// </summary>
|
||||
public DataFormat EditorSerializationFormat { get { return DataFormat.Nodes; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the build serialization format.
|
||||
/// </summary>
|
||||
public DataFormat BuildSerializationFormat { get { return DataFormat.Binary; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the logging policy.
|
||||
/// </summary>
|
||||
public LoggingPolicy LoggingPolicy { get { return LoggingPolicy.LogErrors; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the error handling policy.
|
||||
/// </summary>
|
||||
public ErrorHandlingPolicy ErrorHandlingPolicy { get { return ErrorHandlingPolicy.Resilient; } }
|
||||
|
||||
internal static void LoadInstanceIfAssetExists()
|
||||
{
|
||||
// TODO: @Integration: If you store your config in an asset or file somewhere, load it here.
|
||||
}
|
||||
|
||||
internal static bool HasInstanceLoaded
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: @Integration: If you store your config in an asset or file somewhere, return true here if it is loaded, otherwise false.
|
||||
// If your config is stored in a Unity asset, do NOT load it here; this property is often called from the
|
||||
// serialization thread, meaning you are not allowed to use Unity's API for loading assets here.
|
||||
// If this value is false, default configuration values will be used - the same defaults as are set in this class.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bfaf18dca1f68cc99ebeb0b862179265
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user