Update
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Networking.Character
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Character;
|
||||
using Opsive.UltimateCharacterController.Items.Actions;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Acts as a bridge between the character controller and the underlying networking implementation.
|
||||
/// </summary>
|
||||
public interface INetworkCharacter
|
||||
{
|
||||
/// <summary>
|
||||
/// Loads the inventory's default loadout.
|
||||
/// </summary>
|
||||
void LoadDefaultLoadout();
|
||||
|
||||
/// <summary>
|
||||
/// Equips or unequips the item with the specified ItemIdentifier and slot.
|
||||
/// </summary>
|
||||
/// <param name="itemIdentifierID">The ID of the ItemIdentifier that should be equipped.</param>
|
||||
/// <param name="slotID">The slot of the item that should be equipped.</param>
|
||||
/// <param name="equip">Should the item be equipped? If false it will be unequipped.</param>
|
||||
void EquipUnequipItem(uint itemIdentifierID, int slotID, bool equip);
|
||||
|
||||
/// <summary>
|
||||
/// The ItemIdentifier has been picked up.
|
||||
/// </summary>
|
||||
/// <param name="itemIdentifierID">The ID of the ItemIdentifier that was picked up.</param>
|
||||
/// <param name="amount">The number of ItemIdentifier picked up.</param>
|
||||
/// <param name="slotID">The ID of the slot which the item belongs to.</param>
|
||||
/// <param name="immediatePickup">Was the item be picked up immediately?</param>
|
||||
/// <param name="forceEquip">Should the item be force equipped?</param>
|
||||
void ItemIdentifierPickup(uint itemIdentifierID, int amount, int slotID, bool immediatePickup, bool forceEquip);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all of the items from the inventory.
|
||||
/// </summary>
|
||||
void RemoveAllItems();
|
||||
|
||||
#if ULTIMATE_CHARACTER_CONTROLLER_SHOOTER
|
||||
/// <summary>
|
||||
/// Fires the weapon.
|
||||
/// </summary>
|
||||
/// <param name="itemAction">The ItemAction that is being fired.</param>
|
||||
/// <param name="strength">(0 - 1) value indicating the amount of strength to apply to the shot.</param>
|
||||
void Fire(ItemAction itemAction, float strength);
|
||||
|
||||
/// <summary>
|
||||
/// Starts to reload the item.
|
||||
/// </summary>
|
||||
/// <param name="itemAction">The ItemAction that is being reloaded.</param>
|
||||
void StartItemReload(ItemAction itemAction);
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the item.
|
||||
/// </summary>
|
||||
/// <param name="itemAction">The ItemAction that is being reloaded.</param>
|
||||
/// <param name="fullClip">Should the full clip be force reloaded?</param>
|
||||
void ReloadItem(ItemAction itemAction, bool fullClip);
|
||||
|
||||
/// <summary>
|
||||
/// The item has finished reloading.
|
||||
/// </summary>
|
||||
/// <param name="itemAction">The ItemAction that is being reloaded.</param>
|
||||
/// <param name="success">Was the item reloaded successfully?</param>
|
||||
/// <param name="immediateReload">Should the item be reloaded immediately?</param>
|
||||
void ItemReloadComplete(ItemAction itemAction, bool success, bool immediateReload);
|
||||
#endif
|
||||
|
||||
#if ULTIMATE_CHARACTER_CONTROLLER_MELEE
|
||||
/// <summary>
|
||||
/// The melee weapon hit a collider.
|
||||
/// </summary>
|
||||
/// <param name="itemAction">The ItemAction that caused the collision.</param>
|
||||
/// <param name="hitboxIndex">The index of the hitbox that caused the collision.</param>
|
||||
/// <param name="raycastHit">The raycast that caused the collision.</param>
|
||||
/// <param name="hitGameObject">The GameObject that was hit.</param>
|
||||
/// <param name="hitCharacterLocomotion">The hit Ultimate Character Locomotion component.</param>
|
||||
void MeleeHitCollider(ItemAction itemAction, int hitboxIndex, RaycastHit raycastHit, GameObject hitGameObject, UltimateCharacterLocomotion hitCharacterLocomotion);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Throws the throwable object.
|
||||
/// </summary>
|
||||
/// <param name="itemAction">The ThrowableItem that is performing the throw.</param>
|
||||
void ThrowItem(ItemAction itemAction);
|
||||
|
||||
/// <summary>
|
||||
/// Enables the object mesh renderers for the ThrowableItem.
|
||||
/// </summary>
|
||||
/// <param name="itemAction">The ThrowableItem that is having the renderers enabled.</param>
|
||||
void EnableThrowableObjectMeshRenderers(ItemAction itemAction);
|
||||
|
||||
/// <summary>
|
||||
/// Starts or stops the begin or end actions.
|
||||
/// </summary>
|
||||
/// <param name="itemAction">The MagicItem that is starting or stopping the actions.</param>
|
||||
/// <param name="beginActions">Should the begin actions be started?</param>
|
||||
/// <param name="start">Should the actions be started?</param>
|
||||
void StartStopBeginEndMagicActions(ItemAction itemAction, bool beginActions, bool start);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a magic CastAction.
|
||||
/// </summary>
|
||||
/// <param name="itemAction">The MagicItem that is performing the cast.</param>
|
||||
/// <param name="index">The index of the CastAction.</param>
|
||||
/// <param name="castID">The ID of the cast.</param>
|
||||
/// <param name="direction">The direction of the cast.</param>
|
||||
/// <param name="targetPosition">The target position of the cast.</param>
|
||||
void MagicCast(ItemAction itemAction, int index, uint castID, Vector3 direction, Vector3 targetPosition);
|
||||
|
||||
/// <summary>
|
||||
/// Performs the magic impact.
|
||||
/// </summary>
|
||||
/// <param name="itemAction">The MagicItem that is performing the impact.</param>
|
||||
/// <param name="castID">The ID of the cast.</param>
|
||||
/// <param name="source">The object that originated the impact.</param>
|
||||
/// <param name="target">The object that received the impact.</param>
|
||||
/// <param name="position">The position of the impact.</param>
|
||||
/// <param name="normal">The impact normal direction.</param>
|
||||
void MagicImpact(ItemAction itemAction, uint castID, GameObject source, GameObject target, Vector3 position, Vector3 normal);
|
||||
|
||||
/// <summary>
|
||||
/// Stops the magic CastAction.
|
||||
/// </summary>
|
||||
/// <param name="itemAction">The MagicItem that is stopping the cast.</param>
|
||||
/// <param name="index">The index of the CastAction.</param>
|
||||
/// <param name="castID">The ID of the cast.</param>
|
||||
void StopMagicCast(ItemAction itemAction, int index, uint castID);
|
||||
|
||||
/// <summary>
|
||||
/// Activates or deactives the flashlight.
|
||||
/// </summary>
|
||||
/// <param name="active">Should the flashlight be activated?</param>
|
||||
void ToggleFlashlight(ItemAction itemAction, bool active);
|
||||
|
||||
/// <summary>
|
||||
/// Pushes the target Rigidbody in the specified direction.
|
||||
/// </summary>
|
||||
/// <param name="targetRigidbody">The Rigidbody to push.</param>
|
||||
/// <param name="force">The amount of force to apply.</param>
|
||||
/// <param name="point">The point at which to apply the push force.</param>
|
||||
void PushRigidbody(Rigidbody targetRigidbody, Vector3 force, Vector3 point);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the rotation of the character.
|
||||
/// </summary>
|
||||
/// <param name="rotation">The rotation to set.</param>
|
||||
/// <param name="snapAnimator">Should the animator be snapped into position?</param>
|
||||
void SetRotation(Quaternion rotation, bool snapAnimator);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the position of the character.
|
||||
/// </summary>
|
||||
/// <param name="position">The position to set.</param>
|
||||
/// <param name="snapAnimator">Should the animator be snapped into position?</param>
|
||||
void SetPosition(Vector3 position, bool snapAnimator);
|
||||
|
||||
/// <summary>
|
||||
/// Resets the rotation and position to their default values.
|
||||
/// </summary>
|
||||
void ResetRotationPosition();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the position and rotation of the character.
|
||||
/// </summary>
|
||||
/// <param name="position">The position to set.</param>
|
||||
/// <param name="rotation">The rotation to set.</param>
|
||||
/// <param name="snapAnimator">Should the animator be snapped into position?</param>
|
||||
void SetPositionAndRotation(Vector3 position, Quaternion rotation, bool snapAnimator);
|
||||
|
||||
/// <summary>
|
||||
/// Activates or deactivates the character.
|
||||
/// </summary>
|
||||
/// <param name="active">Is the character active?</param>
|
||||
/// <param name="uiEvent">Should the OnShowUI event be executed?</param>
|
||||
void SetActive(bool active, bool uiEvent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b6972aed025d2e4f8e2cbc8396728ee
|
||||
timeCreated: 1550007357
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Networking.Objects
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Defines an object that can take destruct over the network using the Destructible component.
|
||||
/// </summary>
|
||||
public interface IDestructibleMonitor
|
||||
{
|
||||
/// <summary>
|
||||
/// Destroys the object.
|
||||
/// </summary>
|
||||
/// <param name="hitPosition">The position of the destruction.</param>
|
||||
/// <param name="hitNormal">The normal direction of the destruction.</param>
|
||||
void Destruct(Vector3 hitPosition, Vector3 hitNormal);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a53ff25bbf3b9b84abd4ea9df9541f1b
|
||||
timeCreated: 1561229987
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Networking.Traits
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Defines an object that can take damage over the network using the Health component.
|
||||
/// </summary>
|
||||
public interface INetworkHealthMonitor
|
||||
{
|
||||
/// <summary>
|
||||
/// The object has taken been damaged.
|
||||
/// </summary>
|
||||
/// <param name="amount">The amount of damage taken.</param>
|
||||
/// <param name="position">The position of the damage.</param>
|
||||
/// <param name="direction">The direction that the object took damage from.</param>
|
||||
/// <param name="forceMagnitude">The magnitude of the force that is applied to the object.</param>
|
||||
/// <param name="frames">The number of frames to add the force to.</param>
|
||||
/// <param name="radius">The radius of the explosive damage. If 0 then a non-explosive force will be used.</param>
|
||||
/// <param name="attacker">The GameObject that did the damage.</param>
|
||||
/// <param name="hitCollider">The Collider that was hit.</param>
|
||||
void OnDamage(float amount, Vector3 position, Vector3 direction, float forceMagnitude, int frames, float radius, GameObject attacker, Collider hitCollider);
|
||||
|
||||
/// <summary>
|
||||
/// The object is no longer alive.
|
||||
/// </summary>
|
||||
/// <param name="position">The position of the damage.</param>
|
||||
/// <param name="force">The amount of force applied to the object while taking the damage.</param>
|
||||
/// <param name="attacker">The GameObject that killed the character.</param>
|
||||
void Die(Vector3 position, Vector3 force, GameObject attacker);
|
||||
|
||||
/// <summary>
|
||||
/// Adds amount to health and then to the shield if there is still an amount remaining. Will not go over the maximum health or shield value.
|
||||
/// </summary>
|
||||
/// <param name="amount">The amount of health or shield to add.</param>
|
||||
void Heal(float amount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0776a257c9cf4f45ae8e62b927b07f0
|
||||
timeCreated: 1558375509
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Networking
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains information about the object on the network.
|
||||
/// </summary>
|
||||
public interface INetworkInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Is the networking implementation server authoritative?
|
||||
/// </summary>
|
||||
/// <returns>True if the network transform is server authoritative.</returns>
|
||||
bool IsServerAuthoritative();
|
||||
|
||||
/// <summary>
|
||||
/// Is the game instance on the server?
|
||||
/// </summary>
|
||||
/// <returns>True if the game instance is on the server.</returns>
|
||||
bool IsServer();
|
||||
|
||||
/// <summary>
|
||||
/// Is the character the local player?
|
||||
/// </summary>
|
||||
/// <returns>True if the character is the local player.</returns>
|
||||
bool IsLocalPlayer();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff2268f447f179347b77fcfc7ffd392f
|
||||
timeCreated: 1558400403
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Networking.Traits
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Allows the object to be interacted with on the network.
|
||||
/// </summary>
|
||||
public interface INetworkInteractableMonitor
|
||||
{
|
||||
/// <summary>
|
||||
/// Performs the interaction.
|
||||
/// </summary>
|
||||
/// <param name="character">The character that wants to interactact with the target.</param>
|
||||
void Interact(GameObject character);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fc7c23c2b6cb034e96da76fc50a2551
|
||||
timeCreated: 1560295017
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Networking.Objects
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Items.Actions;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Defines a magic object that can is spawned over the network.
|
||||
/// </summary>
|
||||
public interface INetworkMagicObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the spawn data.
|
||||
/// </summary>
|
||||
/// <param name="character">The character that is instantiating the object.</param>
|
||||
/// <param name="magicItem">The MagicItem that the object belongs to.</param>
|
||||
/// <param name="actionIndex">The index of the action that is instantiating the object.</param>
|
||||
/// <param name="castID">The ID of the cast that is instantiating the object.</param>
|
||||
void Instantiate(GameObject character, MagicItem magicItem, int actionIndex, uint castID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6175230e2fa15d4e9e9c607117f42f5
|
||||
timeCreated: 1558375509
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Networking.Traits
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Defines an object that can respawn over the network using the Respawner component.
|
||||
/// </summary>
|
||||
public interface INetworkRespawnerMonitor
|
||||
{
|
||||
/// <summary>
|
||||
/// Does the respawn by setting the position and rotation to the specified values.
|
||||
/// Enable the GameObject and let all of the listening objects know that the object has been respawned.
|
||||
/// </summary>
|
||||
/// <param name="position">The respawn position.</param>
|
||||
/// <param name="rotation">The respawn rotation.</param>
|
||||
/// <param name="transformChange">Was the position or rotation changed?</param>
|
||||
void Respawn(Vector3 position, Quaternion rotation, bool transformChange);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f38c97c06fc2e5e4582cdfe6d88145b4
|
||||
timeCreated: 1558375509
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,132 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Networking.Game
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Bridge component between the networking spawning system and the ObjectPool.
|
||||
/// </summary>
|
||||
public abstract class NetworkObjectPool : MonoBehaviour
|
||||
{
|
||||
private static NetworkObjectPool s_Instance;
|
||||
private static NetworkObjectPool Instance { get { return s_Instance; } }
|
||||
|
||||
/// <summary>
|
||||
/// Does the NetworkObjectPool exist?
|
||||
/// </summary>
|
||||
/// <returns>True if the NetworkObjectPool exists.</returns>
|
||||
public static bool IsNetworkActive()
|
||||
{
|
||||
return s_Instance != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The object has been enabled.
|
||||
/// </summary>
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
// The object may have been enabled outside of the scene unloading.
|
||||
if (s_Instance == null) {
|
||||
s_Instance = this;
|
||||
SceneManager.sceneUnloaded -= SceneUnloaded;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spawns the object over the network. This does not instantiate a new object on the local client.
|
||||
/// </summary>
|
||||
/// <param name="original">The object that the object was instantiated from.</param>
|
||||
/// <param name="instanceObject">The object that was instantiated from the original object.</param>
|
||||
/// <param name="sceneObject">Is the object owned by the scene? If fales it will be owned by the character.</param>
|
||||
public static void NetworkSpawn(GameObject original, GameObject instanceObject, bool sceneObject)
|
||||
{
|
||||
if (s_Instance == null) {
|
||||
Debug.LogError("Error: Unable to spawn object - the Network Object Pool doesn't exist.");
|
||||
return;
|
||||
}
|
||||
s_Instance.NetworkSpawnInternal(original, instanceObject, sceneObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal method which spawns the object over the network. This does not instantiate a new object on the local client.
|
||||
/// </summary>
|
||||
/// <param name="original">The object that the object was instantiated from.</param>
|
||||
/// <param name="instanceObject">The object that was instantiated from the original object.</param>
|
||||
/// <param name="sceneObject">Is the object owned by the scene? If fales it will be owned by the character.</param>
|
||||
protected abstract void NetworkSpawnInternal(GameObject original, GameObject instanceObject, bool sceneObject);
|
||||
|
||||
/// <summary>
|
||||
/// Destroys the object instance on the network.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to destroy.</param>
|
||||
public static void Destroy(GameObject obj)
|
||||
{
|
||||
if (s_Instance == null) {
|
||||
Debug.LogError("Error: Unable to destroy object - the Network Object Pool doesn't exist.");
|
||||
return;
|
||||
}
|
||||
s_Instance.DestroyInternal(obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal method which destroys the object instance on the network.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to destroy.</param>
|
||||
protected abstract void DestroyInternal(GameObject obj);
|
||||
|
||||
/// <summary>
|
||||
/// Returns if the specified object was spawned with the network object pool.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object instance to determine if was spawned with the object pool.</param>
|
||||
/// <returns>True if the object was spawned with the network object pool.</returns>
|
||||
public static bool SpawnedWithPool(GameObject obj)
|
||||
{
|
||||
if (s_Instance == null) {
|
||||
return false;
|
||||
}
|
||||
return s_Instance.SpawnedWithPoolInternal(obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal method which returns if the specified object was spawned with the network object pool.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object instance to determine if was spawned with the object pool.</param>
|
||||
/// <returns>True if the object was spawned with the network object pool.</returns>
|
||||
protected abstract bool SpawnedWithPoolInternal(GameObject obj);
|
||||
|
||||
/// <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_Instance = null;
|
||||
SceneManager.sceneUnloaded -= SceneUnloaded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The object has been disabled.
|
||||
/// </summary>
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
SceneManager.sceneUnloaded += SceneUnloaded;
|
||||
}
|
||||
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
/// <summary>
|
||||
/// Reset the static variables for domain reloading.
|
||||
/// </summary>
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
private static void DomainReset()
|
||||
{
|
||||
s_Instance = null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 225d9f20a9703f34796ea99a59130722
|
||||
timeCreated: 1557940449
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user