} //END AddEvent //--------------------------------// public void RemoveEvent( BlockEventBase blockEventBase ) //--------------------------------// { if( showDebug ) { Debug.Log( "BlockEvent.cs RemoveEvent() start, blockEventHelpers.Count = " + blockEventHelpers.Count ); } if( blockEventHelpers != null && blockEventHelpers.Count > 0 ) { for( int i = blockEventHelpers.Count - 1; i >= 0; i-- ) { if( blockEventHelpers[i].GetBlockEventBase() == blockEventBase ) { if( showDebug ) { Debug.Log( "BlockEvent.cs RemoveEvent() found matching blockEventBase, removing from the list of blockEventHelpers[" + i + "]" ); } blockEventHelpers.RemoveAt( i ); if( showDebug ) { if( blockEventBase != null ) { Debug.Log( "BlockEvent.cs RemoveEvent() removed from list, the passed in blockEventBase object is not null!" ); } else { Debug.Log( "BlockEvent.cs RemoveEvent() removed from list, the passed in blockEventBase object is null..." ); } } #if UNITY_EDITOR //Wait a moment before calling DestroyImmediate to make sure no logic is running UnityEditor.EditorApplication.delayCall+=()=> { //If we're coming from a Tween Event, we might have a Tween component attached that should be removed if( blockEventBase.GetComponent<bxrTween>() != null ) { DestroyImmediate( blockEventBase.GetComponent<bxrTween>() ); } if( showDebug ) { Debug.Log( "Calling Destroy for blockEventBase = " + gameObject.name ); } DestroyImmediate( blockEventBase.gameObject ); }; #else //If we're coming from a Tween Event, we might have a Tween component attached that should be removed if( blockEventBase.GetComponent<bxrTween>() != null ) { Destroy( blockEventBase.GetComponent<bxrTween>() ); } Destroy( blockEventBase.gameObject ); #endif break; } else { if( showDebug ) { Debug.Log( "BlockEvent.cs RemoveEvent() blockEventHelpers[" + i + "].blockEventBase( " + blockEventBase.gameObject.name + " ) != blockEventBase(" + blockEventBase.gameObject.name + ")!" ); } } } } else if( blockEventBase != null ) { if( showDebug ) { Debug.Log( "BlockEvent.cs RemoveEvent() blockEventHelpers list is empty!" ); } //If the list is empty, we definitely should remove this stray BlockEventBase gameObject #if UNITY_EDITOR //Wait a moment before calling DestroyImmediate to make sure no logic is running UnityEditor.EditorApplication.delayCall+=()=> { //If we're coming from a Tween Event, we might have a Tween component attached that should be removed if( blockEventBase.GetComponent<bxrTween>() != null ) { DestroyImmediate( blockEventBase.GetComponent<bxrTween>() ); } if( showDebug ) { Debug.Log( "Calling Destroy for blockEventBase = " + gameObject.name ); } DestroyImmediate( blockEventBase.gameObject ); }; #else //If we're coming from a Tween Event, we might have a Tween component attached that should be removed if( blockEventBase.GetComponent<bxrTween>() != null ) { Destroy( blockEventBase.GetComponent<bxrTween>() ); } Destroy( blockEventBase.gameObject ); #endif } } //END RemoveEvent
} //END Constructor //-------------------------------------------------------------// public void SetBlockEventBase( BlockEventBase blockEventBase ) //-------------------------------------------------------------// { this.blockEventBase = blockEventBase; } //END SetBlockEventBase