/// <summary> /// Places the decal at the given point. /// </summary> /// <param name="interactionResult">The interaction result this decal is being created for.</param> /// <param name="point">The point at which to place the decal.</param> /// <param name="normal">The surface normal used to set the decal rotation.</param> public override void SetupDecal(DecalInteractionResult interactionResult, Vector3 point, Vector3 normal) { transform.position = point + normal * _decalDistance; if (RotationMode == DecalRotationMode.Random) { transform.rotation = getNormalRotation(normal); rotateRandom(); } else if (RotationMode == DecalRotationMode.Velocity) { transform.rotation = getVelocityRotation(normal, interactionResult.OriginalData.Velocity); } else { transform.rotation = getNormalRotation(normal); } if (ParentToObject && interactionResult.OriginalData.OtherObject) { transform.SetParent(interactionResult.OriginalData.OtherObject.transform); parentObject = interactionResult.OriginalData.OtherObject.GetOrAddComponent <DestroyMessenger>(); parentObject.OnDestroyed += onParentDestroyed; } else { transform.SetParent(OriginalParent, true); } }
public override void MakeAvailable() { if (parentObject) { parentObject.OnDestroyed -= onParentDestroyed; } parentObject = null; base.MakeAvailable(); }
public override void Retrieve() { if (parentObject) { parentObject.OnDestroyed -= onParentDestroyed; } parentObject = null; base.Retrieve(); }