2026-04-22 모듈러 에셋 포함
This commit is contained in:
8
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth.meta
vendored
Normal file
8
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f50424043833af24ebf193a442e9583b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
46
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_MagicaClothCollider.cs
vendored
Normal file
46
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_MagicaClothCollider.cs
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Bozo.AnimeCharacters
|
||||
{
|
||||
public class BoZo_MagicaClothCollider : MonoBehaviour
|
||||
{
|
||||
#if MAGICACLOTH2
|
||||
[SerializeField] Direction direction;
|
||||
[SerializeField] bool reverseDirection;
|
||||
[SerializeField] float length;
|
||||
[SerializeField] float startRadius;
|
||||
[SerializeField] float endRadius;
|
||||
[SerializeField] Vector3 center;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
var col = gameObject.AddComponent<MagicaCloth2.MagicaCapsuleCollider>();
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case Direction.X:
|
||||
col.direction = MagicaCloth2.MagicaCapsuleCollider.Direction.X;
|
||||
break;
|
||||
case Direction.Y:
|
||||
col.direction = MagicaCloth2.MagicaCapsuleCollider.Direction.Y;
|
||||
break;
|
||||
case Direction.Z:
|
||||
col.direction = MagicaCloth2.MagicaCapsuleCollider.Direction.Z;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
col.reverseDirection = reverseDirection;
|
||||
col.SetSize(startRadius, endRadius, length);
|
||||
col.center = center;
|
||||
col.UpdateParameters();
|
||||
}
|
||||
|
||||
private enum Direction { X, Y, Z }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63e462de7adcce6478830a8f97bd9a95
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 323550
|
||||
packageName: 'BoZo: Modular Anime Characters - Base Pack'
|
||||
packageVersion: 1.8.4
|
||||
assetPath: Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_MagicaClothCollider.cs
|
||||
uploadId: 903394
|
||||
287
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_MagicaClothSupport.cs
vendored
Normal file
287
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_MagicaClothSupport.cs
vendored
Normal file
@@ -0,0 +1,287 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Bozo.AnimeCharacters
|
||||
{
|
||||
public class BoZo_MagicaClothSupport : MonoBehaviour, IOutfitExtension<Texture>
|
||||
{
|
||||
public const string id = "MagicaClothExtension";
|
||||
|
||||
bool initalized;
|
||||
private OutfitSystem system;
|
||||
public ClothType type;
|
||||
public SkinnedMeshRenderer skinnedMeshRenderer;
|
||||
public string[] disableByTag;
|
||||
public bool InitalizeOnStart;
|
||||
|
||||
[Header("Bones")]
|
||||
public bool boneReferenceByString;
|
||||
public List<Transform> rootBones;
|
||||
public List<string> rootBonesString;
|
||||
public float collisionSize = 0.025f;
|
||||
public AnimationCurve collisionCurve = new AnimationCurve(new Keyframe(0,1), new Keyframe(1,1));
|
||||
|
||||
[Header("Mesh")]
|
||||
public Texture2D influenceMap;
|
||||
[Range(0, 0.2f)] public float reductionSetting = 0.065f;
|
||||
|
||||
[Header("Preset")]
|
||||
public TextAsset clothPreset;
|
||||
|
||||
public List<Transform> transforms = new List<Transform>();
|
||||
|
||||
#if MAGICACLOTH2
|
||||
MagicaCloth2.MagicaCloth cloth;
|
||||
#endif
|
||||
|
||||
public Texture GetValue() => influenceMap;
|
||||
object IOutfitExtension.GetValue() => influenceMap;
|
||||
public System.Type GetValueType() => typeof(Texture);
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
#if MAGICACLOTH2
|
||||
|
||||
foreach (var item in GetComponents<MagicaCloth2.MagicaCloth>())
|
||||
{
|
||||
if(item != cloth) Destroy(item);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
system = GetComponentInParent<OutfitSystem>();
|
||||
if (system) system.OnRigChanged += OnCharacterMerged;
|
||||
if (system) system.OnOutfitChanged += DisableClothByTag;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
system = GetComponentInParent<OutfitSystem>();
|
||||
if (system) system.OnRigChanged -= OnCharacterMerged;
|
||||
if (system) system.OnOutfitChanged -= DisableClothByTag;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (InitalizeOnStart)
|
||||
{
|
||||
Initalize(null, null);
|
||||
Execute(null, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Initalize(OutfitSystem outfitSystem, Outfit outfit)
|
||||
{
|
||||
#if MAGICACLOTH2
|
||||
if (cloth) Destroy(cloth);
|
||||
cloth = gameObject.AddComponent<MagicaCloth2.MagicaCloth>();
|
||||
|
||||
cloth.Initialize();
|
||||
cloth.DisableAutoBuild();
|
||||
#endif
|
||||
}
|
||||
|
||||
private async void OnCharacterMerged(SkinnedMeshRenderer rig)
|
||||
{
|
||||
#if MAGICACLOTH2
|
||||
if (system == null) return;
|
||||
if (cloth) { Destroy(cloth); cloth = null; }
|
||||
|
||||
initalized = false;
|
||||
if (system.customMaps.ContainsKey(id) && type == ClothType.Mesh)
|
||||
{
|
||||
var map = system.customMaps[id];
|
||||
if (system.customMaps[id].GetType() != typeof(Texture2D))
|
||||
{
|
||||
influenceMap = new Texture2D(map.width, map.height, TextureFormat.RGBA32, false);
|
||||
AsyncGPUReadback.Request(map, 0, OnTextureConversion);
|
||||
}
|
||||
else
|
||||
{
|
||||
influenceMap = (Texture2D)map;
|
||||
Initalize(null, null);
|
||||
Execute(system, null);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Initalize(null, null);
|
||||
Execute(system, null);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void OnTextureConversion(AsyncGPUReadbackRequest request)
|
||||
{
|
||||
if (request.hasError)
|
||||
{
|
||||
Debug.LogError("GPU Readback error occurred.");
|
||||
return;
|
||||
}
|
||||
|
||||
NativeArray<byte> data = request.GetData<byte>();
|
||||
|
||||
influenceMap.LoadRawTextureData(data);
|
||||
influenceMap.Apply();
|
||||
|
||||
Initalize(null, null);
|
||||
Execute(system, null);
|
||||
}
|
||||
|
||||
private void DisableClothByTag(Outfit outfit)
|
||||
{
|
||||
#if MAGICACLOTH2
|
||||
if (system == null || !initalized) return;
|
||||
var enabled = true;
|
||||
foreach (var item in disableByTag)
|
||||
{
|
||||
if (system.ContainsTag(item)) enabled = false;
|
||||
}
|
||||
if (cloth) cloth.enabled = enabled;
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Execute(OutfitSystem outfitSystem, Outfit outfit)
|
||||
{
|
||||
#if MAGICACLOTH2
|
||||
if (outfitSystem)
|
||||
{
|
||||
if (outfitSystem.mergeBase) return;
|
||||
}
|
||||
|
||||
if (initalized) return;
|
||||
|
||||
system = outfitSystem;
|
||||
switch (type)
|
||||
{
|
||||
case ClothType.Mesh:
|
||||
SetMeshCloth(outfitSystem, outfit);
|
||||
break;
|
||||
case ClothType.Bone:
|
||||
SetBoneCloth(outfitSystem, outfit);
|
||||
break;
|
||||
case ClothType.Spring:
|
||||
SetBoneCloth(outfitSystem, outfit);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
initalized = true;
|
||||
if (outfit) DisableClothByTag(outfit);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MAGICACLOTH2
|
||||
private void SetMeshCloth(OutfitSystem outfitSystem, Outfit outfit)
|
||||
{
|
||||
if (influenceMap == null) return;
|
||||
var sdata = cloth.SerializeData;
|
||||
|
||||
SkinnedMeshRenderer smr = null;
|
||||
|
||||
if (skinnedMeshRenderer)
|
||||
{
|
||||
smr = skinnedMeshRenderer;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (outfit) smr = outfit.skinnedRenderer;
|
||||
else smr = outfitSystem.GetCharacterBody();
|
||||
}
|
||||
|
||||
sdata.sourceRenderers.Add(smr);
|
||||
|
||||
sdata.reductionSetting.shapeDistance = reductionSetting;
|
||||
|
||||
sdata.paintMode = MagicaCloth2.ClothSerializeData.PaintMode.Texture_Fixed_Move;
|
||||
|
||||
|
||||
sdata.paintMaps.Add((Texture2D)influenceMap);
|
||||
|
||||
if (clothPreset) cloth.SerializeData.ImportJson(clothPreset.ToString());
|
||||
sdata.radius = new MagicaCloth2.CurveSerializeData(collisionSize, collisionCurve);
|
||||
|
||||
MagicaCloth2.ColliderComponent[] col = null;
|
||||
if (outfitSystem)
|
||||
{
|
||||
col = outfitSystem.GetClothColliders();
|
||||
}
|
||||
else
|
||||
{
|
||||
col = skinnedMeshRenderer.GetComponentsInChildren<MagicaCloth2.ColliderComponent>();
|
||||
}
|
||||
sdata.colliderCollisionConstraint.colliderList = col.ToList();
|
||||
if (outfitSystem) outfitSystem.RebindBody();
|
||||
cloth.enabled = true;
|
||||
cloth.BuildAndRun();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void SetBoneCloth(OutfitSystem outfitSystem, Outfit outfit)
|
||||
{
|
||||
|
||||
var sdata = cloth.SerializeData;
|
||||
if (type == ClothType.Bone) sdata.clothType = MagicaCloth2.ClothProcess.ClothType.BoneCloth;
|
||||
if (type == ClothType.Spring) sdata.clothType = MagicaCloth2.ClothProcess.ClothType.BoneSpring;
|
||||
|
||||
|
||||
SkinnedMeshRenderer smr = null;
|
||||
|
||||
if (skinnedMeshRenderer)
|
||||
{
|
||||
smr = skinnedMeshRenderer;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (outfit) smr = outfit.skinnedRenderer;
|
||||
else smr = outfitSystem.GetCharacterBody();
|
||||
}
|
||||
|
||||
if (rootBonesString.Count != 0)
|
||||
{
|
||||
sdata.rootBones = smr.bones.Where(bone => rootBonesString.Contains(bone.name)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
sdata.rootBones = rootBones;
|
||||
}
|
||||
|
||||
if (clothPreset) cloth.SerializeData.ImportJson(clothPreset.ToString());
|
||||
sdata.radius = new MagicaCloth2.CurveSerializeData(collisionSize, collisionCurve);
|
||||
|
||||
MagicaCloth2.ColliderComponent[] col = null;
|
||||
if (outfitSystem)
|
||||
{
|
||||
col = outfitSystem.GetClothColliders();
|
||||
}
|
||||
else
|
||||
{
|
||||
col = skinnedMeshRenderer.GetComponentsInChildren<MagicaCloth2.ColliderComponent>();
|
||||
}
|
||||
|
||||
if (col != null)sdata.colliderCollisionConstraint.colliderList = col.ToList();
|
||||
|
||||
cloth.enabled = true;
|
||||
cloth.BuildAndRun();
|
||||
}
|
||||
#endif
|
||||
|
||||
public string GetID()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public enum ClothType { Mesh, Bone, Spring }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d2d34769e54eb14398b24dc32eea2c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 323550
|
||||
packageName: 'BoZo: Modular Anime Characters - Base Pack'
|
||||
packageVersion: 1.8.4
|
||||
assetPath: Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_MagicaClothSupport.cs
|
||||
uploadId: 903394
|
||||
1
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_Preset_LongHair.json
vendored
Normal file
1
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_Preset_LongHair.json
vendored
Normal file
File diff suppressed because one or more lines are too long
14
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_Preset_LongHair.json.meta
vendored
Normal file
14
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_Preset_LongHair.json.meta
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99584cca56fc61e408f2d14378fa2059
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 323550
|
||||
packageName: 'BoZo: Modular Anime Characters - Base Pack'
|
||||
packageVersion: 1.8.4
|
||||
assetPath: Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_Preset_LongHair.json
|
||||
uploadId: 903394
|
||||
1
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_Preset_ShortHair.json
vendored
Normal file
1
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_Preset_ShortHair.json
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 433936ba35faf404f921f4a7966526f1
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 323550
|
||||
packageName: 'BoZo: Modular Anime Characters - Base Pack'
|
||||
packageVersion: 1.8.4
|
||||
assetPath: Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_Preset_ShortHair.json
|
||||
uploadId: 903394
|
||||
1
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_Preset_Skirt.json
vendored
Normal file
1
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_Preset_Skirt.json
vendored
Normal file
File diff suppressed because one or more lines are too long
14
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_Preset_Skirt.json.meta
vendored
Normal file
14
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_Preset_Skirt.json.meta
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e136f8a162b7c3f419623d4d87104bb7
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 323550
|
||||
packageName: 'BoZo: Modular Anime Characters - Base Pack'
|
||||
packageVersion: 1.8.4
|
||||
assetPath: Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/BoZo_Preset_Skirt.json
|
||||
uploadId: 903394
|
||||
8
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/Editor.meta
vendored
Normal file
8
Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/Editor.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a24dc9a5633fd9449ac1e9c528ae1eb7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,65 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Bozo.AnimeCharacters
|
||||
{
|
||||
|
||||
[CustomEditor(typeof(BoZo_MagicaClothSupport))]
|
||||
[CanEditMultipleObjects]
|
||||
public class BoZo_MagicaClothSupportEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
#if MAGICACLOTH2
|
||||
BoZo_MagicaClothSupport ob = (BoZo_MagicaClothSupport)target;
|
||||
Color originalColor = GUI.color;
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("InitalizeOnStart"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("type"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("skinnedMeshRenderer"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("disableByTag"));
|
||||
|
||||
|
||||
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
if (ob.type == BoZo_MagicaClothSupport.ClothType.Mesh)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("influenceMap"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("reductionSetting"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("collisionSize"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("collisionCurve"));
|
||||
}
|
||||
else if (ob.type == BoZo_MagicaClothSupport.ClothType.Bone || ob.type == BoZo_MagicaClothSupport.ClothType.Spring)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("boneReferenceByString"));
|
||||
if (ob.boneReferenceByString)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("rootBonesString"));
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("rootBones"));
|
||||
}
|
||||
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("collisionSize"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("collisionCurve"));
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("clothPreset"));
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
//base.OnInspectorGUI();
|
||||
#else
|
||||
EditorGUILayout.LabelField("MagicaCloth2 Not Installed");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1433a1d9f4cc134a8500cb9c5b2be9c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 323550
|
||||
packageName: 'BoZo: Modular Anime Characters - Base Pack'
|
||||
packageVersion: 1.8.4
|
||||
assetPath: Assets/BoZo_ModularAnimeCharacters/Scripts/ThirdParty/MagicaCloth/Editor/BoZo_MagicaClothSupportEditor.cs
|
||||
uploadId: 903394
|
||||
Reference in New Issue
Block a user