Exemplo n.º 1
0
    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();
        }
    }