update CCK to 3.10, fixing unity 2021 crash :)
This commit is contained in:
parent
48a978fa2a
commit
d11e0fb3a9
492 changed files with 2165204 additions and 437687 deletions
154
Assets/ABI.CCK/Scripts/Editor/AssetProcessing/CCK_AssetPostProcessor.cs
Executable file
154
Assets/ABI.CCK/Scripts/Editor/AssetProcessing/CCK_AssetPostProcessor.cs
Executable file
|
@ -0,0 +1,154 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Scripts.Editor.AssetProcessing
|
||||
{
|
||||
/*
|
||||
public class CCK_AssetPostProcessor
|
||||
{
|
||||
#region Configuration
|
||||
|
||||
private const string KEY_PREFIX = "ABI.CCK.AssetPostProcessor.";
|
||||
private static bool AutoHumanoid => EditorPrefs.GetBool("ABI_CCK_AssetPostProcessor_AutoHumanoid", false);
|
||||
private static bool AutoReadWrite => EditorPrefs.GetBool("ABI_CCK_AssetPostProcessor_AutoReadWrite", false);
|
||||
private static bool AutoBlendShapeNormals => EditorPrefs.GetBool("ABI_CCK_AssetPostProcessor_AutoBlendshapeNormals", false);
|
||||
private static bool AutoTextureStreaming => EditorPrefs.GetBool("ABI_CCK_AssetPostProcessor_AutoTextureStreaming", false);
|
||||
|
||||
#endregion
|
||||
|
||||
private static bool _isProcessingModel;
|
||||
private static ModelImporter _modelImporter;
|
||||
|
||||
private static PropertyInfo _legacyBlendShapeImporter;
|
||||
|
||||
private static PropertyInfo legacyBlendShapeImporter
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_legacyBlendShapeImporter != null)
|
||||
return _legacyBlendShapeImporter;
|
||||
|
||||
Type modelImporterType = typeof(ModelImporter);
|
||||
_legacyBlendShapeImporter = modelImporterType.GetProperty(
|
||||
"legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes",
|
||||
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public
|
||||
);
|
||||
|
||||
return _legacyBlendShapeImporter;
|
||||
}
|
||||
}
|
||||
|
||||
#region Asset Post Processing Events
|
||||
|
||||
private void OnPreprocessModel()
|
||||
{
|
||||
_isProcessingModel = false;
|
||||
|
||||
_modelImporter = assetImporter as ModelImporter;
|
||||
if (_modelImporter == null)
|
||||
return;
|
||||
|
||||
// Check if we have already processed this model
|
||||
if (!ShouldProcessAsset(_modelImporter.assetPath, out string assetKey))
|
||||
return;
|
||||
|
||||
_isProcessingModel = true;
|
||||
SessionState.SetBool(assetKey, true);
|
||||
|
||||
SetModelImporterSettings(_modelImporter);
|
||||
}
|
||||
|
||||
private void OnPostprocessMeshHierarchy(GameObject root)
|
||||
{
|
||||
if (!_isProcessingModel)
|
||||
return;
|
||||
|
||||
if (!AutoHumanoid)
|
||||
return;
|
||||
|
||||
// Check if the model should be humanoid
|
||||
|
||||
var childTransforms = root.GetComponentsInChildren<Transform>();
|
||||
|
||||
// Check if the model has enough bones to be humanoid
|
||||
if (childTransforms.Length < HumanTrait.RequiredBoneCount)
|
||||
return;
|
||||
|
||||
// Check if the model has enough *potential* humanoid bones to be humanoid
|
||||
int potentialHumanBoneCount = childTransforms.Count(childTransform =>
|
||||
childTransform.name.IndexOf("armature", StringComparison.OrdinalIgnoreCase) >= 0 ||
|
||||
childTransform.name.IndexOf("hip", StringComparison.OrdinalIgnoreCase) >= 0 ||
|
||||
childTransform.name.IndexOf("hand", StringComparison.OrdinalIgnoreCase) >= 0 ||
|
||||
childTransform.name.IndexOf("head", StringComparison.OrdinalIgnoreCase) >= 0);
|
||||
|
||||
// IKSystem will still filter it if it doesn't have enough bones
|
||||
// VRIK requires hips to head, arms, and either both legs or neither leg.
|
||||
|
||||
if (potentialHumanBoneCount < 3)
|
||||
return;
|
||||
|
||||
_modelImporter.animationType = ModelImporterAnimationType.Human;
|
||||
}
|
||||
|
||||
private void OnPreprocessTexture()
|
||||
{
|
||||
TextureImporter textureImporter = assetImporter as TextureImporter;
|
||||
if (textureImporter == null)
|
||||
return;
|
||||
|
||||
if (!ShouldProcessAsset(textureImporter.assetPath, out string assetKey))
|
||||
return;
|
||||
|
||||
SessionState.SetBool(assetKey, true);
|
||||
|
||||
SetTextureImporterSettings(textureImporter);
|
||||
}
|
||||
|
||||
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
|
||||
{
|
||||
foreach (string deletedAsset in deletedAssets)
|
||||
{
|
||||
string assetKey = KEY_PREFIX + AssetDatabase.AssetPathToGUID(deletedAsset);
|
||||
SessionState.EraseBool(assetKey); // Remove the asset from the list of processed assets, so it can be processed again if re-imported
|
||||
|
||||
CCK_AutoCleanupProcessor.OnProcessDeletedAsset(deletedAsset);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private static bool ShouldProcessAsset(string assetPath, out string assetKey)
|
||||
{
|
||||
assetKey = KEY_PREFIX + AssetDatabase.AssetPathToGUID(assetPath);
|
||||
return !SessionState.GetBool(assetKey, false);
|
||||
}
|
||||
|
||||
// TODO: Is there anything else we need to set?
|
||||
|
||||
private static void SetModelImporterSettings(ModelImporter modelImporter)
|
||||
{
|
||||
if (AutoReadWrite)
|
||||
modelImporter.isReadable = true;
|
||||
|
||||
if (AutoBlendShapeNormals)
|
||||
modelImporter.importBlendShapeNormals = ModelImporterNormals.Import;
|
||||
|
||||
//if(modelImporter.importBlendShapeNormals != ModelImporterNormals.Calculate)
|
||||
legacyBlendShapeImporter.SetValue(modelImporter, true);
|
||||
}
|
||||
|
||||
private static void SetTextureImporterSettings(TextureImporter textureImporter)
|
||||
{
|
||||
if (AutoTextureStreaming)
|
||||
textureImporter.streamingMipmaps = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 983fdec8b2554916a318d13c3cc189a5
|
||||
timeCreated: 1702781676
|
59
Assets/ABI.CCK/Scripts/Editor/AssetProcessing/CCK_AutoCleanupProcessor.cs
Executable file
59
Assets/ABI.CCK/Scripts/Editor/AssetProcessing/CCK_AutoCleanupProcessor.cs
Executable file
|
@ -0,0 +1,59 @@
|
|||
using UnityEditor;
|
||||
|
||||
namespace ABI.CCK.Scripts.Editor.AssetProcessing
|
||||
{
|
||||
/// <summary>
|
||||
/// Cleans up scripting symbols that were added by the CCK when the CCK is deleted.
|
||||
/// This is done to prevent Third Party scripts from spewing compile errors when doing a fresh import or uninstall.
|
||||
/// </summary>
|
||||
public static class CCK_AutoCleanupProcessor
|
||||
{
|
||||
private const string CCK_ROOT_FOLDER = "Assets/ABI.CCK";
|
||||
|
||||
// All scripting symbols that can be added by the CCK
|
||||
private static readonly string[] CCK_SCRIPTING_SYMBOLS =
|
||||
{
|
||||
"CVR_CCK_EXISTS",
|
||||
// third party addons
|
||||
"CCK_ADDIN_TRANSLATABLE_TMP",
|
||||
"CCK_ADDIN_HIGHLIGHT_PLUS",
|
||||
"CCK_ADDIN_MAGICACLOTHSUPPORT"
|
||||
};
|
||||
|
||||
internal static void OnProcessDeletedAsset(string deletedAsset)
|
||||
{
|
||||
if (deletedAsset == CCK_ROOT_FOLDER)
|
||||
OnCCKLikelyDeleted();
|
||||
}
|
||||
|
||||
private static void OnCCKLikelyDeleted()
|
||||
{
|
||||
// Remove for BuildTargetGroups
|
||||
var selectedBuildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup; // just in case somehow user is on unsupported build target group
|
||||
var buildTargetGroups = new[] { BuildTargetGroup.Standalone, BuildTargetGroup.Android, selectedBuildTargetGroup };
|
||||
foreach (BuildTargetGroup buildTargetGroup in buildTargetGroups)
|
||||
{
|
||||
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
|
||||
|
||||
foreach (var scriptingSymbol in CCK_SCRIPTING_SYMBOLS)
|
||||
if (defines.Contains(scriptingSymbol)) // remove all CCK scripting symbols
|
||||
defines = defines.Replace(scriptingSymbol, "");
|
||||
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, defines);
|
||||
}
|
||||
|
||||
// Remove for NamedBuildTarget ???
|
||||
// var buildTargets = new[] { NamedBuildTarget.Standalone, NamedBuildTarget.Android };
|
||||
// foreach (NamedBuildTarget buildTarget in buildTargets)
|
||||
// {
|
||||
// var defines = PlayerSettings.GetScriptingDefineSymbols(buildTarget);
|
||||
//
|
||||
// foreach (var scriptingSymbol in CCK_SCRIPTING_SYMBOLS)
|
||||
// if (defines.Contains(scriptingSymbol)) // remove all CCK scripting symbols
|
||||
// defines = defines.Replace(scriptingSymbol, "");
|
||||
//
|
||||
// PlayerSettings.SetScriptingDefineSymbols(buildTarget, defines);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a1f6a40517314d64bed4c4d97905ccdc
|
||||
timeCreated: 1703188866
|
Loading…
Add table
Add a link
Reference in a new issue