void ChangeBlendSystem()
    {
        Undo.RecordObject(lsTarget, "Change Blend System");

        if (lsTarget.GetComponent <BlendSystem>() != null)
        {
            if (blendSystems[blendSystemNumber] == null)
            {
                BlendSystem[] oldSystems = lsTarget.GetComponents <BlendSystem>();
                foreach (BlendSystem system in oldSystems)
                {
                    system.OnBlendSystemRemoved();
                    DestroyImmediate(blendSystemEditor);
                    Undo.DestroyObjectImmediate(system);
                }
            }
            else if (blendSystems[blendSystemNumber] != lsTarget.GetComponent <BlendSystem>().GetType())
            {
                BlendSystem[] oldSystems = lsTarget.GetComponents <BlendSystem>();
                foreach (BlendSystem system in oldSystems)
                {
                    system.OnBlendSystemRemoved();
                    DestroyImmediate(blendSystemEditor);
                    Undo.DestroyObjectImmediate(system);
                }

                Undo.AddComponent(lsTarget.gameObject, blendSystems[blendSystemNumber]);
                lsTarget.blendSystem = lsTarget.GetComponent <BlendSystem>();
                CreateBlendSystemEditor();
            }
        }
        else if (blendSystems[blendSystemNumber] != null)
        {
            Undo.AddComponent(lsTarget.gameObject, blendSystems[blendSystemNumber]);
            lsTarget.blendSystem = lsTarget.GetComponent <BlendSystem>();
            CreateBlendSystemEditor();
        }
    }
    void OnEnable()
    {
        logo = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Lipsync/Dark/logo_component.png");

        guideAI  = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Lipsync/Guides/AI.png");
        guideE   = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Lipsync/Guides/E.png");
        guideEtc = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Lipsync/Guides/etc.png");
        guideFV  = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Lipsync/Guides/FV.png");
        guideL   = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Lipsync/Guides/L.png");
        guideMBP = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Lipsync/Guides/MBP.png");
        guideO   = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Lipsync/Guides/O.png");
        guideU   = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Lipsync/Guides/U.png");
        guideWQ  = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Lipsync/Guides/WQ.png");

        presetsIcon = (Texture2D)EditorGUIUtility.Load("Rogo Digital/LipSync/Dark/presets.png");

        if (!EditorGUIUtility.isProSkin)
        {
            logo        = (Texture2D)EditorGUIUtility.Load("Rogo Digital/Lipsync/Light/logo_component.png");
            presetsIcon = (Texture2D)EditorGUIUtility.Load("Rogo Digital/LipSync/Light/presets.png");
        }

        guides = new List <Texture2D>()
        {
            guideAI,
            guideE,
            guideU,
            guideO,
            guideEtc,
            guideFV,
            guideL,
            guideMBP,
            guideWQ,
            Texture2D.blackTexture
        };

        Undo.undoRedoPerformed += OnUndoRedoPerformed;

        lsTarget = (LipSync)target;
        lsTarget.reset.AddListener(OnEnable);
        if (lsTarget.blendSystem == null)
        {
            lsTarget.blendSystem = lsTarget.GetComponent <BlendSystem>();
        }

        if (lsTarget.lastUsedVersion < versionNumber)
        {
            AutoUpdate(lsTarget.lastUsedVersion);
            lsTarget.lastUsedVersion = versionNumber;
        }

        serializedTarget = new SerializedObject(target);
        FindBlendSystems();

        audioSource  = serializedTarget.FindProperty("audioSource");
        restTime     = serializedTarget.FindProperty("restTime");
        restHoldTime = serializedTarget.FindProperty("restHoldTime");
        phonemeCurveGenerationMode = serializedTarget.FindProperty("phonemeCurveGenerationMode");
        playOnAwake         = serializedTarget.FindProperty("playOnAwake");
        loop                = serializedTarget.FindProperty("loop");
        defaultClip         = serializedTarget.FindProperty("defaultClip");
        defaultDelay        = serializedTarget.FindProperty("defaultDelay");
        scaleAudioSpeed     = serializedTarget.FindProperty("scaleAudioSpeed");
        animationTimingMode = serializedTarget.FindProperty("animationTimingMode");
        frameRate           = serializedTarget.FindProperty("frameRate");
        useBones            = serializedTarget.FindProperty("useBones");
        boneUpdateAnimation = serializedTarget.FindProperty("boneUpdateAnimation");
        onFinishedPlaying   = serializedTarget.FindProperty("onFinishedPlaying");

        showBoneOptions    = new AnimBool(lsTarget.useBones, Repaint);
        showPlayOnAwake    = new AnimBool(lsTarget.playOnAwake, Repaint);
        showFixedFrameRate = new AnimBool(lsTarget.animationTimingMode == LipSync.AnimationTimingMode.FixedFrameRate, Repaint);

        CreateBlendSystemEditor();

        if (lsTarget.blendSystem != null)
        {
            if (lsTarget.blendSystem.isReady)
            {
                GetBlendShapes();
                blendSystemButtons = GetBlendSystemButtons();
            }
        }

        if (lsTarget.phonemes == null || lsTarget.phonemes.Count < 9)
        {
            lsTarget.phonemes = new List <PhonemeShape>();

            for (int A = 0; A < 10; A++)
            {
                lsTarget.phonemes.Add(new PhonemeShape((Phoneme)A));
            }

            EditorUtility.SetDirty(lsTarget);
            serializedTarget.SetIsDifferentCacheDirty();
        }
        else if (lsTarget.phonemes.Count == 9)
        {
            //Update pre 0.4 characters with the new Rest phoneme
            lsTarget.phonemes.Add(new PhonemeShape(Phoneme.Rest));
        }
    }