/// <summary> /// Instantiates a decal. /// </summary> /// <param name="hit">The RaycastHit which caused the collision.</param> private void SpawnDecal(RaycastHit hit) { var decal = GetDecal(); // The last spawned decal should be remembered so no two decals are spawned immediately after one another if multiple decals can be spawned. m_LastSpawnedDecal = decal; DecalManager.Spawn(decal, hit, Random.Range(m_MinDecalScale, m_MaxDecalScale), m_AllowedDecalEdgeOverlap); }
/// <summary> /// The object has been enabled. /// </summary> private void OnEnable() { // The object may have been enabled outside of the scene unloading. if (s_Instance == null) { s_Instance = this; s_Initialized = true; SceneManager.sceneUnloaded -= SceneUnloaded; } }
/// <summary> /// A footprint and any related effects should be spawned at the hit point. /// </summary> /// <param name="hit">The RaycastHit which caused the collision.</param> /// <param name="gravityDirection">The normalized direction of the character's gravity.</param> /// <param name="timeScale">The timescale of the originator.</param> /// <param name="originator">The object which spawned the effect.</param> /// <param name="spawnDecals">Should the decals be spawned? Not all surfaces allow for decals.</param> /// <param name="footprintDirection">The direction that the footprint decal should face.</param> /// <param name="flipFootprint">Should the footprint decal be flipped?</param> public virtual void SpawnFootprint(RaycastHit hit, Vector3 gravityDirection, float timeScale, GameObject originator, bool spawnDecals, Vector3 footprintDirection, bool flipFootprint) { SpawnObjects(hit, gravityDirection); PlayAudioClip(hit, timeScale, originator); SetState(hit); // Return early if the SurfaceType doesn't allow decals. if (!spawnDecals) { return; } // The DecalManager will do the footprint spawn. DecalManager.SpawnFootprint(GetDecal(), hit, Random.Range(m_MinDecalScale, m_MaxDecalScale), m_AllowedDecalEdgeOverlap, footprintDirection, flipFootprint); }
private static void DomainReset() { s_Initialized = false; s_Instance = null; }
/// <summary> /// Reset the initialized variable when the scene is no longer loaded. /// </summary> /// <param name="scene">The scene that was unloaded.</param> private void SceneUnloaded(Scene scene) { s_Initialized = false; s_Instance = null; SceneManager.sceneUnloaded -= SceneUnloaded; }