mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-15 01:12:05 +07:00
copy-paste fix
This commit is contained in:
@@ -6,71 +6,18 @@ namespace IsoTools.Internal {
|
||||
[RequireComponent(typeof(IsoObject))]
|
||||
public class IsoPhysicHelper : MonoBehaviour {
|
||||
|
||||
static List<IsoCollider> _tmpColliders = new List<IsoCollider>(7);
|
||||
static List<IsoRigidbody> _tmpRigidbodies = new List<IsoRigidbody>(7);
|
||||
static List<IsoTriggerListener> _tmpTriggerListeners = new List<IsoTriggerListener>(7);
|
||||
static List<IsoCollisionListener> _tmpCollisionListeners = new List<IsoCollisionListener>(7);
|
||||
|
||||
GameObject _isoFakeObject = null;
|
||||
public GameObject isoFakeObject {
|
||||
get { return _isoFakeObject; }
|
||||
}
|
||||
|
||||
//TODO: fix copy-paste
|
||||
public void DestroyIfUnnecessary(Component except) {
|
||||
var unnecessary = true;
|
||||
GetComponents<IsoCollider> (_tmpColliders);
|
||||
GetComponents<IsoRigidbody> (_tmpRigidbodies);
|
||||
GetComponents<IsoTriggerListener> (_tmpTriggerListeners);
|
||||
GetComponents<IsoCollisionListener>(_tmpCollisionListeners);
|
||||
if ( unnecessary ) {
|
||||
for ( int i = 0, e = _tmpColliders.Count; i < e; ++i ) {
|
||||
if ( _tmpColliders[i] != except ) {
|
||||
unnecessary = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( unnecessary ) {
|
||||
for ( int i = 0, e = _tmpRigidbodies.Count; i < e; ++i ) {
|
||||
if ( _tmpRigidbodies[i] != except ) {
|
||||
unnecessary = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( unnecessary ) {
|
||||
for ( int i = 0, e = _tmpTriggerListeners.Count; i < e; ++i ) {
|
||||
if ( _tmpTriggerListeners[i] != except ) {
|
||||
unnecessary = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( unnecessary ) {
|
||||
for ( int i = 0, e = _tmpCollisionListeners.Count; i < e; ++i ) {
|
||||
if ( _tmpCollisionListeners[i] != except ) {
|
||||
unnecessary = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_tmpColliders.Clear();
|
||||
_tmpRigidbodies.Clear();
|
||||
_tmpTriggerListeners.Clear();
|
||||
_tmpCollisionListeners.Clear();
|
||||
if ( unnecessary ) {
|
||||
Destroy(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Awake() {
|
||||
hideFlags = HideFlags.HideInInspector;
|
||||
//hideFlags = HideFlags.HideInInspector;
|
||||
var iso_object = GetComponent<IsoObject>();
|
||||
if ( iso_object ) {
|
||||
_isoFakeObject = new GameObject("_Fake" + gameObject.name);
|
||||
_isoFakeObject.AddComponent<IsoFakeObject>().Init(iso_object);
|
||||
_isoFakeObject.hideFlags = HideFlags.HideInHierarchy | HideFlags.NotEditable;
|
||||
//_isoFakeObject.hideFlags = HideFlags.HideInHierarchy | HideFlags.NotEditable;
|
||||
GameObject.DontDestroyOnLoad(_isoFakeObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IsoTools.Internal {
|
||||
public class IsoPhysicHelperHolder : MonoBehaviour {
|
||||
|
||||
static List<IsoPhysicHelperHolder> _tmpHolders = new List<IsoPhysicHelperHolder>(7);
|
||||
|
||||
protected GameObject fakeObject {
|
||||
get { return physicHelper.isoFakeObject; }
|
||||
}
|
||||
@@ -12,7 +15,18 @@ namespace IsoTools.Internal {
|
||||
}
|
||||
|
||||
protected void DestroyUnnecessaryCheck() {
|
||||
physicHelper.DestroyIfUnnecessary(this);
|
||||
var unnecessary = true;
|
||||
GetComponents<IsoPhysicHelperHolder>(_tmpHolders);
|
||||
for ( int i = 0, e = _tmpHolders.Count; i < e; ++i ) {
|
||||
if ( _tmpHolders[i] != this ) {
|
||||
unnecessary = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( unnecessary ) {
|
||||
Destroy(physicHelper);
|
||||
}
|
||||
_tmpHolders.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user