Ejemplo n.º 1
0
        /// <summary>
        /// Destroys loose preset objects that live in memory and not in assets
        /// </summary>
        public static void CleanupPresetsOfType <T>() where T : PumkinPreset
        {
            var tools = PumkinsAvatarTools.Instance;

            foreach (var p in GameObject.FindObjectsOfType <T>())
            {
                if (p && string.IsNullOrEmpty(AssetDatabase.GetAssetPath(p)))
                {
                    Debug.Log("Destroying orphanned " + typeof(T).Name);
                    GameObject.DestroyImmediate(p);
                }
            }

            if (typeof(T) == typeof(PumkinsCameraPreset))
            {
                CameraPresets.RemoveAll(o => o == default(PumkinsCameraPreset) || string.IsNullOrEmpty(AssetDatabase.GetAssetPath(o)) || string.IsNullOrEmpty(o.name));
            }
            else if (typeof(T) == typeof(PumkinsPosePreset))
            {
                PosePresets.RemoveAll(o => o == default(PumkinsPosePreset) || string.IsNullOrEmpty(AssetDatabase.GetAssetOrScenePath(o)) || string.IsNullOrEmpty(o.name));
            }
            else if (typeof(T) == typeof(PumkinsBlendshapePreset))
            {
                BlendshapePresets.RemoveAll(o => o == default(PumkinsBlendshapePreset) || string.IsNullOrEmpty(AssetDatabase.GetAssetOrScenePath(o)) || string.IsNullOrEmpty(o.name));
            }

            PumkinsAvatarTools.RefreshPresetIndex <T>();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Destroys loose preset objects that live in memory and not in assets
        /// </summary>
        public static void CleanupPresetsOfType <T>() where T : PumkinPreset
        {
            var    tools    = PumkinsAvatarTools.Instance;
            string typeName = typeof(T).Name;
            var    presets  = GameObject.FindObjectsOfType <T>();

            Type t  = typeof(T);
            Type tP = typeof(PumkinPreset);

            foreach (var preset in presets)
            {
                if (preset && !Helpers.IsAssetInAssets(preset))
                {
                    PumkinsAvatarTools.LogVerbose($"Destroying orphanned {typeName}");
                    Helpers.DestroyAppropriate(preset);
                }
            }

            if (typeof(T) == typeof(PumkinsCameraPreset) || t == tP)
            {
                CameraPresets.RemoveAll(o => o == default(PumkinsCameraPreset) || !Helpers.IsAssetInAssets(o));
            }
            if (typeof(T) == typeof(PumkinsPosePreset) || t == tP)
            {
                PosePresets.RemoveAll(o => o == default(PumkinsPosePreset) || !Helpers.IsAssetInAssets(o));
            }
            if (typeof(T) == typeof(PumkinsBlendshapePreset) || t == tP)
            {
                BlendshapePresets.RemoveAll(o => o == default(PumkinsBlendshapePreset) || !Helpers.IsAssetInAssets(o));
            }

            PumkinsAvatarTools.RefreshPresetIndex <T>();
        }