2026-06-20 뉴페어리
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
// Magica Cloth 2.
|
||||
// Copyright (c) 2024 MagicaSoft.
|
||||
// https://magicasoft.jp
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MagicaCloth2
|
||||
{
|
||||
/// <summary>
|
||||
/// PreBuildの保存アセットデータ
|
||||
/// </summary>
|
||||
[CreateAssetMenu(fileName = "Data", menuName = "MagicaCloth2/PreBuildScriptableObject")]
|
||||
public class PreBuildScriptableObject : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 複数のPreBuildデータを格納可能
|
||||
/// </summary>
|
||||
public List<SharePreBuildData> sharePreBuildDataList = new List<SharePreBuildData>();
|
||||
|
||||
//=========================================================================================
|
||||
public bool HasPreBuildData(string buildId)
|
||||
{
|
||||
return GetPreBuildData(buildId) != null;
|
||||
}
|
||||
|
||||
public SharePreBuildData GetPreBuildData(string buildId)
|
||||
{
|
||||
foreach (var sdata in sharePreBuildDataList)
|
||||
{
|
||||
if (sdata.CheckBuildId(buildId))
|
||||
return sdata;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void AddPreBuildData(SharePreBuildData sdata)
|
||||
{
|
||||
int index = sharePreBuildDataList.FindIndex(x => x.buildId == sdata.buildId);
|
||||
if (index >= 0)
|
||||
sharePreBuildDataList[index] = sdata;
|
||||
else
|
||||
sharePreBuildDataList.Add(sdata);
|
||||
}
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// すべてのPreBuildデータをデシリアライズしてマネージャに登録します
|
||||
/// この処理は負荷が高いため事前に実行しておくことでクロスデータ利用時の負荷を軽減できます
|
||||
/// Deserialize all PreBuild data and register it with the manager.
|
||||
/// This process requires a high load, so running it in advance can reduce the load when using cross data.
|
||||
/// </summary>
|
||||
public void Warmup()
|
||||
{
|
||||
if (Application.isPlaying == false)
|
||||
return;
|
||||
|
||||
sharePreBuildDataList.ForEach(sdata =>
|
||||
{
|
||||
MagicaManager.PreBuild.RegisterPreBuildData(sdata, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45b12b58fd27b9a4bae4f50db55b4459
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 242307
|
||||
packageName: Magica Cloth 2
|
||||
packageVersion: 2.18.1
|
||||
assetPath: Assets/MagicaCloth2/Scripts/Core/PreBuild/PreBuildScriptableObject.cs
|
||||
uploadId: 893596
|
||||
@@ -0,0 +1,101 @@
|
||||
// Magica Cloth 2.
|
||||
// Copyright (c) 2024 MagicaSoft.
|
||||
// https://magicasoft.jp
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MagicaCloth2
|
||||
{
|
||||
/// <summary>
|
||||
/// PreBuildの保存データ
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class PreBuildSerializeData : ITransform
|
||||
{
|
||||
/// <summary>
|
||||
/// 有効状態
|
||||
/// Valid state.
|
||||
/// </summary>
|
||||
public bool enabled = false;
|
||||
|
||||
/// <summary>
|
||||
/// ビルド識別ID
|
||||
/// </summary>
|
||||
public string buildId;
|
||||
|
||||
/// <summary>
|
||||
/// ビルドデータの共有部分
|
||||
/// このデータは複数のインスタンスで共有されるためScriptableObjectとして外部アセットとして保存される
|
||||
/// </summary>
|
||||
public PreBuildScriptableObject preBuildScriptableObject = null;
|
||||
|
||||
/// <summary>
|
||||
/// ビルドデータの固有部分
|
||||
/// このデータはインスタンスごとに固有となる
|
||||
/// </summary>
|
||||
public UniquePreBuildData uniquePreBuildData;
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// PreBuild利用の有無
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool UsePreBuild() => enabled;
|
||||
|
||||
/// <summary>
|
||||
/// PreBuildデータの検証
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ResultCode DataValidate()
|
||||
{
|
||||
if (uniquePreBuildData == null)
|
||||
return new ResultCode(Define.Result.PreBuildData_Empty);
|
||||
|
||||
var preBuildData = GetSharePreBuildData();
|
||||
if (preBuildData == null)
|
||||
return new ResultCode(Define.Result.PreBuildData_Empty);
|
||||
|
||||
var result = preBuildData.DataValidate();
|
||||
if (result.IsFaild())
|
||||
return result;
|
||||
|
||||
result = uniquePreBuildData.DataValidate();
|
||||
if (result.IsFaild())
|
||||
return result;
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
public SharePreBuildData GetSharePreBuildData()
|
||||
{
|
||||
if (preBuildScriptableObject == null)
|
||||
return null;
|
||||
|
||||
if (string.IsNullOrEmpty(buildId))
|
||||
return null;
|
||||
|
||||
return preBuildScriptableObject.GetPreBuildData(buildId); ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ビルドIDを生成する(英数字8文字)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GenerateBuildID()
|
||||
{
|
||||
Guid g = Guid.NewGuid();
|
||||
return g.ToString().Substring(0, 8);
|
||||
}
|
||||
|
||||
public void GetUsedTransform(HashSet<Transform> transformSet)
|
||||
{
|
||||
uniquePreBuildData.GetUsedTransform(transformSet);
|
||||
}
|
||||
|
||||
public void ReplaceTransform(Dictionary<MagicaObjectId, Transform> replaceDict)
|
||||
{
|
||||
uniquePreBuildData.ReplaceTransform(replaceDict);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c7522d5a2a34f84c9588683c5574fa9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 242307
|
||||
packageName: Magica Cloth 2
|
||||
packageVersion: 2.18.1
|
||||
assetPath: Assets/MagicaCloth2/Scripts/Core/PreBuild/PreBuildSerializeData.cs
|
||||
uploadId: 893596
|
||||
@@ -0,0 +1,69 @@
|
||||
// Magica Cloth 2.
|
||||
// Copyright (c) 2024 MagicaSoft.
|
||||
// https://magicasoft.jp
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MagicaCloth2
|
||||
{
|
||||
/// <summary>
|
||||
/// PreBuildデータの共有部分
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SharePreBuildData
|
||||
{
|
||||
public int version;
|
||||
public string buildId;
|
||||
public ResultCode buildResult;
|
||||
public Vector3 buildScale;
|
||||
|
||||
public List<RenderSetupData.ShareSerializationData> renderSetupDataList = new List<RenderSetupData.ShareSerializationData>();
|
||||
|
||||
public VirtualMesh.ShareSerializationData proxyMesh;
|
||||
public List<VirtualMesh.ShareSerializationData> renderMeshList = new List<VirtualMesh.ShareSerializationData>();
|
||||
|
||||
public DistanceConstraint.ConstraintData distanceConstraintData;
|
||||
public TriangleBendingConstraint.ConstraintData bendingConstraintData;
|
||||
public InertiaConstraint.ConstraintData inertiaConstraintData;
|
||||
|
||||
//=========================================================================================
|
||||
public ResultCode DataValidate()
|
||||
{
|
||||
if (version != Define.System.LatestPreBuildVersion)
|
||||
return new ResultCode(Define.Result.PreBuildData_VersionMismatch);
|
||||
|
||||
if (buildScale.x < Define.System.Epsilon)
|
||||
return new ResultCode(Define.Result.PreBuildData_InvalidScale);
|
||||
|
||||
if (buildResult.IsFaild())
|
||||
return buildResult;
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
public bool CheckBuildId(string buildId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(buildId))
|
||||
return false;
|
||||
|
||||
return this.buildId == buildId;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(1024);
|
||||
|
||||
sb.AppendLine("<<<<< PreBuildData >>>>>");
|
||||
sb.AppendLine($"Version:{version}");
|
||||
sb.AppendLine($"BuildID:{buildId}");
|
||||
sb.AppendLine($"BuildResult:{buildResult.GetResultString()}");
|
||||
sb.AppendLine($"BuildScale:{buildScale}");
|
||||
sb.AppendLine(proxyMesh.ToString());
|
||||
sb.AppendLine($"renderMeshList:{renderMeshList.Count}");
|
||||
sb.AppendLine($"renderSetupDataList:{renderSetupDataList.Count}");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 280185e34f035f44d999fc83fffe8ab9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 242307
|
||||
packageName: Magica Cloth 2
|
||||
packageVersion: 2.18.1
|
||||
assetPath: Assets/MagicaCloth2/Scripts/Core/PreBuild/SharePreBuildData.cs
|
||||
uploadId: 893596
|
||||
@@ -0,0 +1,49 @@
|
||||
// Magica Cloth 2.
|
||||
// Copyright (c) 2024 MagicaSoft.
|
||||
// https://magicasoft.jp
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MagicaCloth2
|
||||
{
|
||||
/// <summary>
|
||||
/// PreBuildデータの固有部分
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class UniquePreBuildData : ITransform
|
||||
{
|
||||
public int version;
|
||||
public ResultCode buildResult;
|
||||
|
||||
public List<RenderSetupData.UniqueSerializationData> renderSetupDataList = new List<RenderSetupData.UniqueSerializationData>();
|
||||
|
||||
public VirtualMesh.UniqueSerializationData proxyMesh;
|
||||
public List<VirtualMesh.UniqueSerializationData> renderMeshList = new List<VirtualMesh.UniqueSerializationData>();
|
||||
|
||||
//=========================================================================================
|
||||
public ResultCode DataValidate()
|
||||
{
|
||||
if (version != Define.System.LatestPreBuildVersion)
|
||||
return new ResultCode(Define.Result.PreBuildData_VersionMismatch);
|
||||
|
||||
if (buildResult.IsFaild())
|
||||
return buildResult;
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
public void GetUsedTransform(HashSet<Transform> transformSet)
|
||||
{
|
||||
renderSetupDataList.ForEach(x => x?.GetUsedTransform(transformSet));
|
||||
proxyMesh?.GetUsedTransform(transformSet);
|
||||
renderMeshList.ForEach(x => x?.GetUsedTransform(transformSet));
|
||||
}
|
||||
|
||||
public void ReplaceTransform(Dictionary<MagicaObjectId, Transform> replaceDict)
|
||||
{
|
||||
renderSetupDataList.ForEach(x => x?.ReplaceTransform(replaceDict));
|
||||
proxyMesh?.ReplaceTransform(replaceDict);
|
||||
renderMeshList.ForEach(x => x?.ReplaceTransform(replaceDict));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cee094d81395864ba3ef342016a8de6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 242307
|
||||
packageName: Magica Cloth 2
|
||||
packageVersion: 2.18.1
|
||||
assetPath: Assets/MagicaCloth2/Scripts/Core/PreBuild/UniquePreBuildData.cs
|
||||
uploadId: 893596
|
||||
Reference in New Issue
Block a user