Example #1
0
    MadSprite BuildSlide(MadSprite template, string anchorName, bool left)
    {
        MadAnchor slideAnchor = MadTransform.FindChildWithName <MadAnchor>(transform, anchorName);

        if (slideAnchor != null)
        {
            DestroyImmediate(slideAnchor.gameObject);
        }

        slideAnchor = CreateChild <MadAnchor>(anchorName);
        if (hideManagedObjects)
        {
            slideAnchor.gameObject.hideFlags = HideFlags.HideInHierarchy;
        }

        slideAnchor.position = left ? MadAnchor.Position.Left : MadAnchor.Position.Right;
        slideAnchor.Update(); // explict update call because position has changed

        var offset = MadTransform.CreateChild(slideAnchor.transform, "Offset");

        offset.transform.localPosition =
            new Vector3(left ? template.texture.width / 2 : -template.texture.width / 2, 0, 0);

        var slide = MadTransform.CreateChild <MadSprite>(offset.transform, "slide", template);

        slide.transform.localScale    = Vector3.one;
        slide.transform.localPosition = Vector3.zero;
        slide.guiDepth = 1000;

        return(slide);
    }
Example #2
0
    protected void OnEnable() {
        sprite = target as MadSprite;

        panel = serializedObject.FindProperty("panel");
        visible = serializedObject.FindProperty("visible");
        pivotPoint = serializedObject.FindProperty("pivotPoint");
        customPivotPoint = serializedObject.FindProperty("customPivotPoint");
        tint = serializedObject.FindProperty("tint");
        inputType = serializedObject.FindProperty("inputType");
        texture = serializedObject.FindProperty("texture");
        textureAtlas = serializedObject.FindProperty("textureAtlas");
        textureAtlasSpriteGUID = serializedObject.FindProperty("textureAtlasSpriteGUID");
        textureOffset = serializedObject.FindProperty("textureOffset");
        textureRepeat = serializedObject.FindProperty("textureRepeat");
        hasPremultipliedAlpha = serializedObject.FindProperty("hasPremultipliedAlpha");
        guiDepth = serializedObject.FindProperty("guiDepth");
        fillType = serializedObject.FindProperty("fillType");
        fillValue = serializedObject.FindProperty("fillValue");
        radialFillOffset = serializedObject.FindProperty("radialFillOffset");
        radialFillLength = serializedObject.FindProperty("radialFillLength");

        hasLiveBounds = serializedObject.FindProperty("hasLiveBounds");
        liveLeft = serializedObject.FindProperty("liveLeft");
        liveBottom = serializedObject.FindProperty("liveBottom");
        liveRight = serializedObject.FindProperty("liveRight");
        liveTop = serializedObject.FindProperty("liveTop");

        gridTexture = Resources.Load("Mad2D/Textures/grid", typeof(Texture2D)) as Texture2D;
        whiteTexture = Resources.Load("Textures/white", typeof(Texture2D)) as Texture2D;

        
    }
Example #3
0
    bool CanBatch(MadSprite a, MadSprite b)
    {
        var materialA = a.GetMaterial();
        var materialB = b.GetMaterial();

        return(materialA.Equals(materialB));
    }
    protected void OnEnable()
    {
        sprite = target as MadSprite;

        panel                  = serializedObject.FindProperty("panel");
        visible                = serializedObject.FindProperty("visible");
        pivotPoint             = serializedObject.FindProperty("pivotPoint");
        customPivotPoint       = serializedObject.FindProperty("customPivotPoint");
        tint                   = serializedObject.FindProperty("tint");
        inputType              = serializedObject.FindProperty("inputType");
        texture                = serializedObject.FindProperty("texture");
        textureAtlas           = serializedObject.FindProperty("textureAtlas");
        textureAtlasSpriteGUID = serializedObject.FindProperty("textureAtlasSpriteGUID");
        textureOffset          = serializedObject.FindProperty("textureOffset");
        textureRepeat          = serializedObject.FindProperty("textureRepeat");
        hasPremultipliedAlpha  = serializedObject.FindProperty("hasPremultipliedAlpha");
        guiDepth               = serializedObject.FindProperty("guiDepth");
        fillType               = serializedObject.FindProperty("fillType");
        fillValue              = serializedObject.FindProperty("fillValue");
        radialFillOffset       = serializedObject.FindProperty("radialFillOffset");
        radialFillLength       = serializedObject.FindProperty("radialFillLength");

        hasLiveBounds = serializedObject.FindProperty("hasLiveBounds");
        liveLeft      = serializedObject.FindProperty("liveLeft");
        liveBottom    = serializedObject.FindProperty("liveBottom");
        liveRight     = serializedObject.FindProperty("liveRight");
        liveTop       = serializedObject.FindProperty("liveTop");

        gridTexture  = Resources.Load("Mad2D/Textures/grid", typeof(Texture2D)) as Texture2D;
        whiteTexture = Resources.Load("Textures/white", typeof(Texture2D)) as Texture2D;
    }
Example #5
0
    void BuildSlideIcons()
    {
        if (leftSlideSprite == null || rightSlideSprite == null)
        {
            Debug.LogWarning("Slide prefabs not set yet.");
            return;
        }

        slideLeft  = BuildSlide(leftSlideSprite, "SlideLeftAnchor", true);
        slideRight = BuildSlide(rightSlideSprite, "SlideRightAnchor", false);

        slideLeft.transform.localScale  = new Vector3(leftSlideScale.x, leftSlideScale.y, 1);
        slideRight.transform.localScale = new Vector3(rightSlideScale.x, rightSlideScale.y, 1);

        slideLeft.transform.localPosition  += (Vector3)leftSlideOffset;
        slideRight.transform.localPosition += (Vector3)rightSlideOffset;

        MadSprite.Action goToPrevPage = (sprite) => {
            if (HasPrevPage())
            {
                GoToPrevPage();
            }
        };
        slideLeft.onTap     += goToPrevPage;
        slideLeft.onMouseUp += goToPrevPage;

        MadSprite.Action goToNextPage = (sprite) => {
            if (HasNextPage())
            {
                GoToNextPage();
            }
        };
        slideRight.onTap     += goToNextPage;
        slideRight.onMouseUp += goToNextPage;
    }
    private void Invoke(MadSprite sprite) {
        var cam = Camera.main;
        if (cam == null) {
            cam = FindObjectOfType(typeof (Camera)) as Camera;
        }

        AudioSource.PlayClipAtPoint(audioClip, cam.transform.position, volume);
    }
Example #7
0
    // ===========================================================
    // Methods
    // ===========================================================

    void CreateGrid(MadRootNode root, MadLevelIcon icon, MadSprite slideLeft, MadSprite slideRight) {
        var panel = MadTransform.FindChild<MadPanel>(root.transform);
        var gridLayout = MadLevelGridTool.CreateUnderPanel(panel);

        gridLayout.iconTemplate = icon;
        gridLayout.leftSlideSprite = slideLeft;
        gridLayout.rightSlideSprite = slideRight;
        gridLayout.dirty = true;
    }
Example #8
0
    static void SlideSetActive(MadSprite icon, bool act)
    {
        bool currentlyActive = MadGameObject.IsActive(icon.gameObject);

        if (currentlyActive != act)
        {
            MadGameObject.SetActive(icon.gameObject, act);
        }
    }
Example #9
0
    // ===========================================================
    // Methods
    // ===========================================================

    void CreateGrid(MadRootNode root, MadLevelIcon icon, MadSprite slideLeft, MadSprite slideRight)
    {
        var panel      = MadTransform.FindChild <MadPanel>(root.transform);
        var gridLayout = MadLevelGridTool.CreateUnderPanel(panel);

        gridLayout.iconTemplate     = icon;
        gridLayout.leftSlideSprite  = slideLeft;
        gridLayout.rightSlideSprite = slideRight;
        gridLayout.dirty            = true;
    }
Example #10
0
    private void Invoke(MadSprite sprite)
    {
        var cam = Camera.main;

        if (cam == null)
        {
            cam = FindObjectOfType(typeof(Camera)) as Camera;
        }

        AudioSource.PlayClipAtPoint(audioClip, cam.transform.position, volume);
    }
Example #11
0
 void Start()
 {
     icon   = MadTransform.FindParent <MadLevelIcon>(transform);
     sprite = GetComponent <MadSprite>();
     if (icon != null)
     {
         AssignTexture();
     }
     else
     {
         Debug.LogError("MadLevelImage may be set only as a MadLevelIcon child");
     }
 }
Example #12
0
    protected override void Start() {
        sprite = GetComponent<MadSprite>();
        if (sprite == null) {
            Debug.Log("Anim Color component requires MadSprite component!", this);
            return;
        }

        origin = sprite.tint;

        easingFunction = MadiTween.GetEasingFunction(easing);

        base.Start();
    }
Example #13
0
    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    // ===========================================================
    // Methods
    // ===========================================================
    
    void Start() {
        sprite = GetComponent<MadSprite>();
        if (sprite != null) {
            sprite.onMouseEnter += (s) => AnimOnMouseEnter();
            sprite.onMouseExit += (s) => AnimOnMouseExit();
            sprite.onTouchEnter += (s) => AnimOnTouchEnter();
            sprite.onTouchExit += (s) => AnimOnTouchExit();
            sprite.onFocus += (s) => PlayOnFocus();
            sprite.onFocusLost += (s) => PlayOnFocusLost();
        } else {
            Debug.LogError("This component must be attached with sprite!", this);
        }
    }
Example #14
0
    static void SlideSetActive(MadSprite icon, bool act)
    {
        if (!MadGameObject.IsActive(icon.gameObject))
        {
            MadGameObject.SetActive(icon.gameObject, true);
        }

        bool currentlyActive = icon.visible;

        if (currentlyActive != act)
        {
            icon.visible = act;
        }
    }
Example #15
0
    bool IsDragging(MadSprite sprite)
    {
        var dragHandler = sprite.FindParent <MadDraggable>();

        if (dragHandler != null)
        {
            if (dragHandler.dragging)
            {
                return(true);
            }
        }

        return(false);
    }
    void Start() {
        sprite = GetComponent<MadSprite>();
        if (sprite == null) {
            Debug.LogError("Condition needs a MadSprite to be attached to this game object.", this);
            return;
        }

        icon = MadTransform.FindParent<MadLevelIcon>(transform);
        if (icon == null) {
            Debug.LogError("Condition need to be set under MadLevelIcon.", this);
            return;
        }

        Apply();
    }
Example #17
0
    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    // ===========================================================
    // Methods
    // ===========================================================

    void Start()
    {
        sprite = GetComponent <MadSprite>();
        if (sprite != null)
        {
            sprite.onMouseEnter += (s) => AnimOnMouseEnter();
            sprite.onMouseExit  += (s) => AnimOnMouseExit();
            sprite.onFocus      += (s) => PlayOnFocus();
            sprite.onFocusLost  += (s) => PlayOnFocusLost();
        }
        else
        {
            Debug.LogError("This component must be attached with sprite!", this);
        }
    }
Example #18
0
    protected override void Start()
    {
        sprite = GetComponent <MadSprite>();
        if (sprite == null)
        {
            Debug.Log("Anim Color component requires MadSprite component!", this);
            return;
        }

        origin = sprite.tint;

        easingFunction = MadiTween.GetEasingFunction(easing);

        base.Start();
    }
Example #19
0
    void InitTemplates(MadRootNode root, out MadLevelIcon icon, out MadSprite slideLeftSprite,
                       out MadSprite slideRightSprite)
    {
        var panel     = MadTransform.FindChild <MadPanel>(root.transform);
        var templates = MadTransform.CreateChild(panel.transform, "Templates");

        GameObject iconPrefab       = (GameObject)AssetDatabase.LoadAssetAtPath(IconPrefab, typeof(GameObject));
        GameObject slideLeftPrefab  = (GameObject)AssetDatabase.LoadAssetAtPath(SlideLeftPrefab, typeof(GameObject));
        GameObject slideRightPrefab = (GameObject)AssetDatabase.LoadAssetAtPath(SlideRightPrefab, typeof(GameObject));

        if (MadGameObject.AnyNull(iconPrefab, slideLeftPrefab, slideRightPrefab))
        {
            Debug.LogWarning("I cannot find all needed prefabs to create example templates. Have you moved Mad Level "
                             + "Manager directory to other than default place?");
        }

        if (iconPrefab != null)
        {
            var obj = MadTransform.CreateChild(templates.transform, "icon", iconPrefab);
            icon = obj.GetComponent <MadLevelIcon>();
        }
        else
        {
            icon = null;
        }

        if (slideLeftPrefab != null)
        {
            var slide = MadTransform.CreateChild(templates.transform, "slide left", slideLeftPrefab);
            slideLeftSprite = slide.GetComponent <MadSprite>();
        }
        else
        {
            slideLeftSprite = null;
        }

        if (slideRightPrefab != null)
        {
            var slide = MadTransform.CreateChild(templates.transform, "slide right", slideRightPrefab);
            slideRightSprite = slide.GetComponent <MadSprite>();
        }
        else
        {
            slideRightSprite = null;
        }

        MadGameObject.SetActive(templates, false);
    }
Example #20
0
    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    protected void OnEnable()
    {
        sprite = target as MadSprite;

        visible          = serializedObject.FindProperty("visible");
        pivotPoint       = serializedObject.FindProperty("pivotPoint");
        tint             = serializedObject.FindProperty("tint");
        texture          = serializedObject.FindProperty("texture");
        textureOffset    = serializedObject.FindProperty("textureOffset");
        textureRepeat    = serializedObject.FindProperty("textureRepeat");
        guiDepth         = serializedObject.FindProperty("guiDepth");
        fillType         = serializedObject.FindProperty("fillType");
        fillValue        = serializedObject.FindProperty("fillValue");
        radialFillOffset = serializedObject.FindProperty("radialFillOffset");
        radialFillLength = serializedObject.FindProperty("radialFillLength");
    }
    void Start()
    {
        sprite = GetComponent <MadSprite>();
        if (sprite == null)
        {
            Debug.LogError("Condition needs a MadSprite to be attached to this game object.", this);
            return;
        }

        icon = MadTransform.FindParent <MadLevelIcon>(transform);
        if (icon == null)
        {
            Debug.LogError("Condition need to be set under MadLevelIcon.", this);
            return;
        }

        Apply();
    }
Example #22
0
    static void SlideSetActive(MadSprite icon, bool act) {
        bool currentlyActive = MadGameObject.IsActive(icon.gameObject);

        if (currentlyActive != act) {
            MadGameObject.SetActive(icon.gameObject, act);
        }
    }
    static void SlideSetActive(MadSprite icon, bool act) {
        if (!MadGameObject.IsActive(icon.gameObject)) {
            MadGameObject.SetActive(icon.gameObject, true);
        }

        bool currentlyActive = icon.visible;

        if (currentlyActive != act) {
            icon.visible = act;
        }
    }
    private void BuildSlideIcons() {
        if (leftSlideSprite == null || rightSlideSprite == null) {
            return;
        }

        slideLeft = BuildSlide(leftSlideSprite, "SlideLeftAnchor", true);
        slideRight = BuildSlide(rightSlideSprite, "SlideRightAnchor", false);

        slideLeft.transform.localScale = new Vector3(leftSlideScale.x, leftSlideScale.y, 1);
        slideRight.transform.localScale = new Vector3(rightSlideScale.x, rightSlideScale.y, 1);

        slideLeft.transform.localPosition += (Vector3) leftSlideOffset;
        slideRight.transform.localPosition += (Vector3) rightSlideOffset;

        MadSprite.Action goToPrevPage = (sprite) => {
            if (HasPrevPage()) {
                GoToPrevPage();
            }
        };
        slideLeft.onTap += goToPrevPage;
        slideLeft.onMouseUp += goToPrevPage;

        MadSprite.Action goToNextPage = (sprite) => {
            if (HasNextPage()) {
                GoToNextPage();
            }
        };
        slideRight.onTap += goToNextPage;
        slideRight.onMouseUp += goToNextPage;
    }
Example #25
0
 public void PlayFinishAnimation(MadSprite chosenSprite, bool completed) {
     levelNameText.eventFlags = MadSprite.EventFlags.None;
     argumentsText.eventFlags = MadSprite.EventFlags.None;
     backToMenu.eventFlags = MadSprite.EventFlags.None;
 
     Color transparent = new Color(1, 1, 1, 0);
     Color opaque = new Color(1, 1, 1, 1);
     
     levelNameText.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
     argumentsText.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
     backToMenu.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
     
     if (completed) {
         levelCompletedText.tint = transparent;
         levelCompletedText.visible = true;
         levelCompletedText.AnimColorTo(opaque, 1, MadiTween.EaseType.linear);
     } else {
         levelNotCompletedText.tint = transparent;
         levelNotCompletedText.visible = true;
         levelNotCompletedText.AnimColorTo(opaque, 1, MadiTween.EaseType.linear);
     }
     
     foreach (var sprite in other) {
         var children = MadTransform.FindChildren<MadSprite>(sprite.transform);
         
         sprite.eventFlags = MadSprite.EventFlags.None;
         foreach (var s in children) {
             s.eventFlags = MadSprite.EventFlags.None;
         }
     
         if (sprite != chosenSprite) {
             sprite.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
             
             foreach (var s in children) {
                 s.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
             }
         }
     }
     
     chosenSprite.AnimMoveTo(new Vector3(), 1, MadiTween.EaseType.easeOutSine);
         
     MadiTween.ScaleTo(chosenSprite.gameObject, MadiTween.Hash(
         "scale", new Vector3(7, 7, 7),
         "time", 0.5f,
         "easetype", MadiTween.EaseType.easeInQuint,
         "delay", 1.5f
     ));
     
     MadiTween.ValueTo(chosenSprite.gameObject, MadiTween.Hash(
         "from", chosenSprite.tint,
         "to", transparent,
         "time", 0.5f,
         "onupdate", "OnTintChange",
         "easetype", MadiTween.EaseType.easeInQuint,
         "delay", 1.5f
     ));
         
     foreach (var s in MadTransform.FindChildren<MadSprite>(chosenSprite.transform)) {
         MadiTween.ValueTo(s.gameObject, MadiTween.Hash(
             "from", s.tint,
             "to", transparent,
             "time", 0.5f,
             "onupdate", "OnTintChange",
                 "easetype", MadiTween.EaseType.easeInQuint,
             "delay", 1.5f
         ));
     }
 }
Example #26
0
 void NullAction(MadSprite s)
 {
 }
Example #27
0
    void InitTemplates(MadRootNode root, out MadLevelIcon icon, out MadSprite slideLeftSprite,
            out MadSprite slideRightSprite) {
        var panel = MadTransform.FindChild<MadPanel>(root.transform);
        var templates = MadTransform.CreateChild(panel.transform, "Templates");

        GameObject iconPrefab = MadAssets.TryLoadGameObject(IconPrefabGUID);
        GameObject slideLeftPrefab = MadAssets.TryLoadGameObject(SlideLeftPrefabGUID);
        GameObject slideRightPrefab = MadAssets.TryLoadGameObject(SlideRightPrefabGUID);

        if (MadGameObject.AnyNull(iconPrefab, slideLeftPrefab, slideRightPrefab)) {
            Debug.LogWarning("I cannot find all needed prefabs to create example templates. Have you removed Mad Level "
            + "Manager example prefabs?");
        }

        if (iconPrefab != null) {
            var obj = PrefabUtility.InstantiatePrefab(iconPrefab) as GameObject;
            obj.transform.parent = templates.transform;
            obj.name = "icon";

            obj.transform.localScale = Vector3.one;
            obj.transform.localPosition = new Vector2(-400, 150);
            icon = obj.GetComponent<MadLevelIcon>();
        } else {
            icon = null;
        }

        if (slideLeftPrefab != null) {
            var slide = PrefabUtility.InstantiatePrefab(slideLeftPrefab) as GameObject;
            slide.transform.parent = templates.transform;
            slide.name = "slide left";

            slide.transform.localScale = Vector3.one;
            slide.transform.localPosition = new Vector2(-400, 0);
            slideLeftSprite = slide.GetComponent<MadSprite>();
        } else {
            slideLeftSprite = null;
        }

        if (slideRightPrefab != null) {
            var slide = PrefabUtility.InstantiatePrefab(slideRightPrefab) as GameObject;
            slide.transform.parent = templates.transform;
            slide.name = "slide right";

            slide.transform.localScale = Vector3.one;
            slide.transform.localPosition = new Vector2(-400, -150);
            slideRightSprite = slide.GetComponent<MadSprite>();
        } else {
            slideRightSprite = null;
        }

        MadGameObject.SetActive(templates, false);
    }
Example #28
0
    bool IsDragging(MadSprite sprite) {
        var dragHandler = sprite.FindParent<MadDraggable>();
        if (dragHandler != null) {
            if (dragHandler.dragging) {
                return true;
            }
        }

        return false;
    }
    bool CanBatch(MadSprite a, MadSprite b) {
        if (panel.renderMode == MadPanel.RenderMode.DepthBased) {
            if (a.guiDepth != b.guiDepth) {
                return false;
            }
        }

        var materialA = a.GetMaterial();
        var materialB = b.GetMaterial();
        
        return materialA.Equals(materialB);
    }
    private bool SpriteVisible(MadSprite sprite) {
        bool active =
#if UNITY_3_5
        sprite.gameObject.active;
#else
        sprite.gameObject.activeInHierarchy;
#endif
        if (!active) {
            return false;
        }

        if (!sprite.visible) {
            return false;
        }

        if (Mathf.Approximately(sprite.tint.a, 0)) {
            return false;
        }

        if (!sprite.CanDraw()) {
            return false;
        }

        if (panel.hideInvisibleSprites && Application.isPlaying) {
            // execute camera visiblity check only if playing (not working in the edit mode)

            sprite.GetWorldCorners(ref cornersWorker);
            var cam = panel.currentCamera;
            if (!VisibleOnCameraAny(cornersWorker, cam)) {
                return false;
            }
        }

        return true;
    }
Example #31
0
 void NullAction(MadSprite s) {}
Example #32
0
 bool CanBatch(MadSprite a, MadSprite b) {
     var materialA = a.GetMaterial();
     var materialB = b.GetMaterial();
     
     return materialA.Equals(materialB);
 }
Example #33
0
    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    // ===========================================================
    // Methods
    // ===========================================================

    void Start() {
        loadingScreen = FindObjectOfType(typeof(MadLevelLoadingScreen)) as MadLevelLoadingScreen;
        bar = GetComponent<MadSprite>();
    }
    private MadSprite BuildSlide(MadSprite template, string anchorName, bool left) {
        var slideAnchor = MadTransform.CreateChild<MadAnchor>(transform, anchorName);
        if (hideManagedObjects) {
            slideAnchor.gameObject.hideFlags = HideFlags.HideInHierarchy;
        }

        slideAnchor.position = left ? MadAnchor.Position.Left : MadAnchor.Position.Right;
        slideAnchor.Update(); // explict update call because position has changed

        var offset = MadTransform.CreateChild(slideAnchor.transform, "Offset");
        offset.transform.localPosition =
            new Vector3(left ? template.texture.width / 2 : -template.texture.width / 2, 0, 0);

        var slide = MadTransform.CreateChild<MadSprite>(offset.transform, "slide", template);
        slide.transform.localScale = Vector3.one;
        slide.transform.localPosition = Vector3.zero;
        slide.guiDepth = 50;

        return slide;
    }
Example #35
0
    void InitTemplates(MadRootNode root, out MadLevelIcon icon, out MadSprite slideLeftSprite,
                       out MadSprite slideRightSprite)
    {
        var panel     = MadTransform.FindChild <MadPanel>(root.transform);
        var templates = MadTransform.CreateChild(panel.transform, "Templates");

        GameObject iconPrefab       = MadAssets.TryLoadGameObject(IconPrefabGUID);
        GameObject slideLeftPrefab  = MadAssets.TryLoadGameObject(SlideLeftPrefabGUID);
        GameObject slideRightPrefab = MadAssets.TryLoadGameObject(SlideRightPrefabGUID);

        if (MadGameObject.AnyNull(iconPrefab, slideLeftPrefab, slideRightPrefab))
        {
            Debug.LogWarning("I cannot find all needed prefabs to create example templates. Have you removed Mad Level "
                             + "Manager example prefabs?");
        }

        if (iconPrefab != null)
        {
            var obj = PrefabUtility.InstantiatePrefab(iconPrefab) as GameObject;
            obj.transform.parent = templates.transform;
            obj.name             = "icon";

            obj.transform.localScale    = Vector3.one;
            obj.transform.localPosition = new Vector2(-400, 150);
            icon = obj.GetComponent <MadLevelIcon>();
        }
        else
        {
            icon = null;
        }

        if (slideLeftPrefab != null)
        {
            var slide = PrefabUtility.InstantiatePrefab(slideLeftPrefab) as GameObject;
            slide.transform.parent = templates.transform;
            slide.name             = "slide left";

            slide.transform.localScale    = Vector3.one;
            slide.transform.localPosition = new Vector2(-400, 0);
            slideLeftSprite = slide.GetComponent <MadSprite>();
        }
        else
        {
            slideLeftSprite = null;
        }

        if (slideRightPrefab != null)
        {
            var slide = PrefabUtility.InstantiatePrefab(slideRightPrefab) as GameObject;
            slide.transform.parent = templates.transform;
            slide.name             = "slide right";

            slide.transform.localScale    = Vector3.one;
            slide.transform.localPosition = new Vector2(-400, -150);
            slideRightSprite = slide.GetComponent <MadSprite>();
        }
        else
        {
            slideRightSprite = null;
        }

        MadGameObject.SetActive(templates, false);
    }
    public void PlayFinishAnimation(MadSprite chosenSprite, bool completed)
    {
        levelNameText.eventFlags = MadSprite.EventFlags.None;
        argumentsText.eventFlags = MadSprite.EventFlags.None;
        backToMenu.eventFlags    = MadSprite.EventFlags.None;

        Color transparent = new Color(1, 1, 1, 0);
        Color opaque      = new Color(1, 1, 1, 1);

        levelNameText.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
        argumentsText.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
        backToMenu.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);

        if (completed)
        {
            levelCompletedText.tint    = transparent;
            levelCompletedText.visible = true;
            levelCompletedText.AnimColorTo(opaque, 1, MadiTween.EaseType.linear);
        }
        else
        {
            levelNotCompletedText.tint    = transparent;
            levelNotCompletedText.visible = true;
            levelNotCompletedText.AnimColorTo(opaque, 1, MadiTween.EaseType.linear);
        }

        foreach (var sprite in other)
        {
            var children = MadTransform.FindChildren <MadSprite>(sprite.transform);

            sprite.eventFlags = MadSprite.EventFlags.None;
            foreach (var s in children)
            {
                s.eventFlags = MadSprite.EventFlags.None;
            }

            if (sprite != chosenSprite)
            {
                sprite.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);

                foreach (var s in children)
                {
                    s.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
                }
            }
        }

        chosenSprite.AnimMoveTo(new Vector3(), 1, MadiTween.EaseType.easeOutSine);

        MadiTween.ScaleTo(chosenSprite.gameObject, MadiTween.Hash(
                              "scale", new Vector3(7, 7, 7),
                              "time", 0.5f,
                              "easetype", MadiTween.EaseType.easeInQuint,
                              "delay", 1.5f
                              ));

        MadiTween.ValueTo(chosenSprite.gameObject, MadiTween.Hash(
                              "from", chosenSprite.tint,
                              "to", transparent,
                              "time", 0.5f,
                              "onupdate", "OnTintChange",
                              "easetype", MadiTween.EaseType.easeInQuint,
                              "delay", 1.5f
                              ));

        foreach (var s in MadTransform.FindChildren <MadSprite>(chosenSprite.transform))
        {
            MadiTween.ValueTo(s.gameObject, MadiTween.Hash(
                                  "from", s.tint,
                                  "to", transparent,
                                  "time", 0.5f,
                                  "onupdate", "OnTintChange",
                                  "easetype", MadiTween.EaseType.easeInQuint,
                                  "delay", 1.5f
                                  ));
        }
    }