添加插件

This commit is contained in:
2025-11-10 00:08:26 +08:00
parent 4059c207c0
commit 76f80db694
2814 changed files with 436400 additions and 178 deletions

View File

@@ -0,0 +1,51 @@
using UnityEngine;
namespace Obi.Samples
{
[RequireComponent(typeof(ObiSolver))]
public class ColliderHighlighter : MonoBehaviour
{
ObiSolver solver;
void Awake()
{
solver = GetComponent<Obi.ObiSolver>();
}
void OnEnable()
{
solver.OnCollision += Solver_OnCollision;
}
void OnDisable()
{
solver.OnCollision -= Solver_OnCollision;
}
void Solver_OnCollision(object sender, ObiNativeContactList e)
{
var colliderWorld = ObiColliderWorld.GetInstance();
for (int i = 0; i < e.count; ++i)
{
Oni.Contact c = e[i];
// make sure this is an actual contact:
if (c.distance < 0.01f)
{
// get the collider:
var col = colliderWorld.colliderHandles[c.bodyB].owner;
if (col != null)
{
// make it blink:
Blinker blinker = col.GetComponent<Blinker>();
if (blinker)
blinker.Blink();
}
}
}
}
}
}