Netcode Bootstrap
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace Rukhanka.Hybrid
|
||||
{
|
||||
public class BoneVisualizationAuthoring: MonoBehaviour
|
||||
{
|
||||
public float tripodSize;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class BoneVisualizationBaker: Baker<BoneVisualizationAuthoring>
|
||||
{
|
||||
public override void Bake(BoneVisualizationAuthoring a)
|
||||
{
|
||||
#if !UNITY_SERVER
|
||||
var e = GetEntity(TransformUsageFlags.Dynamic);
|
||||
var bvc = new BoneVisualizationComponent()
|
||||
{
|
||||
tripodSize = a.tripodSize
|
||||
};
|
||||
AddComponent(e, bvc);
|
||||
#endif
|
||||
|
||||
#if (RUKHANKA_NO_DEBUG_DRAWER && RUKHANKA_DEBUG_INFO)
|
||||
Debug.LogWarning($"'{a.name}' rig visualization was requested, but DebugDrawer is compiled out via RUKHANKA_NO_DEBUG_DRAWER script symbol. No visualization is available.");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7815096ff0c4dc8438b8349dd733f220
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 298480
|
||||
packageName: Rukhanka Animation System 2
|
||||
packageVersion: 2.9.0
|
||||
assetPath: Packages/com.rukhanka.animation/Rukhanka.Hybrid/DebugAndVisualization/BoneVisualizationAuthoring.cs
|
||||
uploadId: 897522
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
using Unity.Entities.Hybrid.Baking;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace Rukhanka.Hybrid
|
||||
{
|
||||
|
||||
[WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]
|
||||
[UpdateAfter(typeof(BakingOnlyEntityAuthoringBakingSystem))]
|
||||
partial class BoneVisualizationConversionSystem : SystemBase
|
||||
{
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
#if RUKHANKA_DEBUG_INFO
|
||||
if (!SystemAPI.TryGetSingleton<DebugConfigurationComponent>(out var dcc) || !dcc.visualizeAllRigs)
|
||||
return;
|
||||
|
||||
var ecb = new EntityCommandBuffer(Allocator.Temp);
|
||||
|
||||
foreach (var (_, e) in SystemAPI.Query<RigDefinitionComponent>()
|
||||
.WithEntityAccess()
|
||||
.WithOptions(EntityQueryOptions.IncludePrefab)
|
||||
.WithNone<BoneVisualizationComponent>())
|
||||
{
|
||||
// Add BoneVisualizationComponent to every animated entity
|
||||
ecb.AddComponent<BoneVisualizationComponent>(e);
|
||||
}
|
||||
|
||||
ecb.Playback(EntityManager);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ab9d0065e6372b44a2f943adf816075
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 298480
|
||||
packageName: Rukhanka Animation System 2
|
||||
packageVersion: 2.9.0
|
||||
assetPath: Packages/com.rukhanka.animation/Rukhanka.Hybrid/DebugAndVisualization/BoneVisualizationConversionSystem.cs
|
||||
uploadId: 897522
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
using Unity.Entities;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace Rukhanka.Hybrid
|
||||
{
|
||||
public class RukhankaDebugConfiguration: MonoBehaviour
|
||||
{
|
||||
[Header("Bone Visualization")]
|
||||
public bool visualizeAllRigs;
|
||||
public Color boneColorCPURig = new
|
||||
(
|
||||
DebugConfigurationComponent.CPU_RIG_COLOR.x,
|
||||
DebugConfigurationComponent.CPU_RIG_COLOR.y,
|
||||
DebugConfigurationComponent.CPU_RIG_COLOR.z,
|
||||
DebugConfigurationComponent.CPU_RIG_COLOR.w
|
||||
);
|
||||
public Color boneColorGPURig = new
|
||||
(
|
||||
DebugConfigurationComponent.GPU_RIG_COLOR.x,
|
||||
DebugConfigurationComponent.GPU_RIG_COLOR.y,
|
||||
DebugConfigurationComponent.GPU_RIG_COLOR.z,
|
||||
DebugConfigurationComponent.GPU_RIG_COLOR.w
|
||||
);
|
||||
|
||||
[Header("Skinned Mesh Bounds")]
|
||||
public bool visualizeSkinnedMeshBounds;
|
||||
public Color staticBoundsColor = new
|
||||
(
|
||||
DebugConfigurationComponent.STATIC_BOUNDS_COLOR.x,
|
||||
DebugConfigurationComponent.STATIC_BOUNDS_COLOR.y,
|
||||
DebugConfigurationComponent.STATIC_BOUNDS_COLOR.z,
|
||||
DebugConfigurationComponent.STATIC_BOUNDS_COLOR.w
|
||||
);
|
||||
public Color dynamicBoundsColor = new
|
||||
(
|
||||
DebugConfigurationComponent.DYNAMIC_BOUNDS_COLOR.x,
|
||||
DebugConfigurationComponent.DYNAMIC_BOUNDS_COLOR.y,
|
||||
DebugConfigurationComponent.DYNAMIC_BOUNDS_COLOR.z,
|
||||
DebugConfigurationComponent.DYNAMIC_BOUNDS_COLOR.w
|
||||
);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public class DebugConfigurationBaker: Baker<RukhankaDebugConfiguration>
|
||||
{
|
||||
public override void Bake(RukhankaDebugConfiguration a)
|
||||
{
|
||||
var dcc = DebugConfigurationComponent.Default();
|
||||
|
||||
dcc.visualizeAllRigs = a.visualizeAllRigs;
|
||||
dcc.cpuRigColor = new float4(a.boneColorCPURig.r, a.boneColorCPURig.g, a.boneColorCPURig.b, a.boneColorCPURig.a);
|
||||
dcc.gpuRigColor = new float4(a.boneColorGPURig.r, a.boneColorGPURig.g, a.boneColorGPURig.b, a.boneColorGPURig.a);
|
||||
dcc.visualizeMeshBounds = a.visualizeSkinnedMeshBounds;
|
||||
dcc.staticMeshBoundsColor = new float4(a.staticBoundsColor.r, a.staticBoundsColor.g, a.staticBoundsColor.b, a.staticBoundsColor.a);
|
||||
dcc.dynamicMeshBoundsColor = new float4(a.dynamicBoundsColor.r, a.dynamicBoundsColor.g, a.dynamicBoundsColor.b, a.dynamicBoundsColor.a);
|
||||
|
||||
var e = GetEntity(TransformUsageFlags.None);
|
||||
AddComponent(e, dcc);
|
||||
|
||||
#if (RUKHANKA_NO_DEBUG_DRAWER && RUKHANKA_DEBUG_INFO)
|
||||
if (a.visualizeAllRigs)
|
||||
Debug.LogWarning("All rigs visualization was requested, but DebugDrawer is compiled out via RUKHANKA_NO_DEBUG_DRAWER script symbol. No visualization is available.");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 050c017b0a715da438609e4964d1226d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 298480
|
||||
packageName: Rukhanka Animation System 2
|
||||
packageVersion: 2.9.0
|
||||
assetPath: Packages/com.rukhanka.animation/Rukhanka.Hybrid/DebugAndVisualization/RukhankaDebugConfiguration.cs
|
||||
uploadId: 897522
|
||||
Reference in New Issue
Block a user