Exemple #1
0
        /// <summary>
        /// Get new Decal and set Transform. If Pooling is enabled on DecalData, Decal will be taken from Pool.
        /// </summary>
        /// <param name="decalData">DecalData to create Decal from.</param>
        /// <param name="position">World space position for Decal.</param>
        /// <param name="direction">World space forward direction for Decal.</param>
        /// <param name="scale">Local space scale for Decal.</param>
        /// <returns></returns>
        public static Decal GetDecal(DecalData decalData, Vector3 position, Vector3 direction, Vector2 scale)
        {
            var decal = GetDecal(decalData);

            decal.SetTransform(position, direction, scale);
            return(decal);
        }
Exemple #2
0
        static Decal CreateDecal(DecalData decalData)
        {
            // Create new Decal
            var name  = decalData.name;
            var obj   = new GameObject(name, typeof(Decal));
            var decal = obj.GetComponent <Decal>();

            decal.decalData = decalData;
            return(decal);
        }
Exemple #3
0
        /// <summary>
        /// Tests whether Pool exists for DecalData.
        /// </summary>
        /// <param name="decalData">Key to test for.</param>
        /// <returns>True if Pool exists.</returns>
        public static bool HasDecalPool(DecalData decalData)
        {
            // Test for pooling enabled
            if (!decalData.poolingEnabled)
            {
                Debug.LogWarning($"Pooling is not enabled for DecalData ({decalData.name})");
                return(false);
            }

            // Test for matching Pool
            return(PoolingSystem.HasPool <Decal>(decalData));
        }
Exemple #4
0
        /// <summary>
        /// Destroy Pool of Decals.
        /// </summary>
        /// <param name="decalData">Key for Pool to destroy.</param>
        public static void DestroyDecalPool(DecalData decalData)
        {
            // Test for pooling enabled
            if (!decalData.poolingEnabled)
            {
                Debug.LogWarning($"Pooling is not enabled for DecalData ({decalData.name})");
                return;
            }

            // Destroy Pool
            PoolingSystem.DestroyPool <Decal>(decalData);
        }
Exemple #5
0
        /// <summary>
        /// Create Pool for Decals using DecalData as key.
        /// </summary>
        /// <param name="decalData">DecalData to create Decals from.</param>
        public static void CreateDecalPool(DecalData decalData)
        {
            // Test for pooling enabled
            if (!decalData.poolingEnabled)
            {
                Debug.LogWarning($"Pooling is not enabled for DecalData ({decalData.name})");
                return;
            }

            // Create Pool
            var decal = CreateDecal(decalData);

            PoolingSystem.CreatePool(decalData, decal, decalData.instanceCount);

            // Cleanup
            DestroyGameObject(decal.gameObject);
        }
Exemple #6
0
        /// <summary>
        /// Get new Decal. If Pooling is enabled on DecalData, Decal will be taken from Pool.
        /// </summary>
        /// <param name="decalData">DecalData to create Decal from.</param>
        /// <returns></returns>
        public static Decal GetDecal(DecalData decalData)
        {
            // Test for pooling enabled
            if (decalData.poolingEnabled)
            {
                // Create Pool
                if (!HasDecalPool(decalData))
                {
                    CreateDecalPool(decalData);
                }

                // Get Decal from Pool
                Decal decal;
                PoolingSystem.TryGetInstance(decalData, out decal);
                return(decal);
            }

            // Create new Decal
            return(CreateDecal(decalData));
        }