示例#1
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DestroyAll
        /// # Destroy all destroyable objects given baseName (optional)
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        public static void DestroyAll(bool byBaseName, string baseName)
        {
            foreach (Object destroyable in GameObject.FindObjectsOfType(typeof(GenericDestroyable)))
            {
                GenericDestroyable actualDestroyable = destroyable as GenericDestroyable;

                bool validDestroyable = true;

                if (byBaseName && (actualDestroyable.GetBaseName() != baseName))
                {
                    //Debug.Log ("Invalid base name: " + actualDestroyable.GetBaseName () + ", need to be " + baseName);
                    validDestroyable = false;
                }

                if (validDestroyable)
                {
                    Object.DestroyImmediate(actualDestroyable.gameObject, true);
                }
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DeleteLastAction
        /// # Handle "delete last" action
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void DeleteLastAction()
        {
            //Debug.Log("Delete Last");

            bool   doItByName = false;
            string baseName   = "";

            switch (systemMode)
            {
            case cSystemMode.edition:
            {
            }
            break;

            case cSystemMode.meshDecals:
            {
                doItByName = true;
                baseName   = BasicDefines.MESH_DECAL_BASE_NAME;
            }
            break;

            case cSystemMode.projectedDecals:
            {
                doItByName = true;
                baseName   = BasicDefines.PROJECTED_DECAL_BASE_NAME;
            }
            break;

            case cSystemMode.objects:
            {
                doItByName = true;
                baseName   = BasicDefines.OBJECT_BASE_NAME;
            }
            break;
            }


            GenericDestroyable.DestroyLast(GetSeedForInstancies(), doItByName, baseName);
        }
示例#3
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DestroyLast
        /// # Destroy last object in scene given seed and basename (optional)
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        public static void DestroyLast(string seed, bool byBaseName, string baseName)
        {
            int maxIndex = -1;

            GenericDestroyable destroyableToDelete = null;

            foreach (Object destroyable in GameObject.FindObjectsOfType(typeof(GenericDestroyable)))
            {
                GenericDestroyable actualDestroyable = destroyable as GenericDestroyable;

                bool validDestroyable = true;

                if (actualDestroyable.GetSeed() != seed)
                {
                    validDestroyable = false;
                }

                if (byBaseName && (actualDestroyable.GetBaseName() != baseName))
                {
                    validDestroyable = false;
                }

                if (validDestroyable)
                {
                    if (actualDestroyable.GetIndex() > maxIndex)
                    {
                        maxIndex            = actualDestroyable.GetIndex();
                        destroyableToDelete = actualDestroyable;
                    }
                }
            }

            if (destroyableToDelete)
            {
                Object.DestroyImmediate(destroyableToDelete.gameObject, true);
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DeleteAllAction
        /// # Handle "delete all" action
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void DeleteAllAction()
        {
            //Debug.Log("Delete All");

            bool   deleteMeshDecals      = false;
            bool   deleteProjectedDecals = false;
            bool   deleteObjects         = false;
            bool   doItByBaseName        = false;
            string baseName = "";

            switch (systemMode)
            {
            case cSystemMode.edition:
            {
                deleteMeshDecals      = true;
                deleteProjectedDecals = true;
                deleteObjects         = true;
            }
            break;

            case cSystemMode.meshDecals:
            {
                deleteMeshDecals = true;
                doItByBaseName   = true;
                baseName         = BasicDefines.MESH_DECAL_BASE_NAME;
            }
            break;

            case cSystemMode.projectedDecals:
            {
                deleteProjectedDecals = true;
                doItByBaseName        = true;
                baseName = BasicDefines.PROJECTED_DECAL_BASE_NAME;
            }
            break;

            case cSystemMode.objects:
            {
                deleteObjects  = true;
                doItByBaseName = true;
                baseName       = BasicDefines.OBJECT_BASE_NAME;
            }
            break;
            }

            if (deleteMeshDecals)
            {
                GenericDestroyable.DestroyAll(doItByBaseName, baseName);
                BasicFunctions.DestroyGameObjectByName(baseName);
            }

            if (deleteProjectedDecals)
            {
                GenericDestroyable.DestroyAll(doItByBaseName, baseName);
                BasicFunctions.DestroyGameObjectByName(baseName);
            }

            if (deleteObjects)
            {
                GenericDestroyable.DestroyAll(doItByBaseName, baseName);
                BasicFunctions.DestroyGameObjectByName(baseName);
            }
        }