更新obi到7.1

This commit is contained in:
Bob.Song
2025-11-03 11:53:45 +08:00
parent d12e1bc495
commit 7cf7f545bc
1161 changed files with 158924 additions and 37802 deletions

View File

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