// ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    public override MadLevelIcon GetIcon(string levelName)
    {
        MadDebug.Assert(!string.IsNullOrEmpty(levelName), "null or empty level name");
        return(MadTransform.FindChild <MadLevelIcon>(draggable.transform, (icon) => {
            return MadGameObject.IsActive(icon.gameObject) && icon.level.name == levelName;
        }, 0));
    }
Example #2
0
    void CreateFree(MadRootNode root, MadLevelIcon icon)
    {
        var panel      = MadTransform.FindChild <MadPanel>(root.transform);
        var freeLayout = MadLevelFreeTool.CreateUnderPanel(panel);

        freeLayout.iconTemplate = icon;
        freeLayout.dirty        = true;
    }
Example #3
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 #4
0
    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    public override MadLevelIcon GetIcon(string levelName)
    {
        var icon = MadTransform.FindChild <MadLevelIcon>(transform, (i) => i.level.name == levelName);

        if (icon != null)
        {
            return(icon);
        }

        return(null);
    }
Example #5
0
        static bool ValidateHasGridLayout()
        {
            var panel = MadPanel.UniqueOrNull();

            if (panel == null)
            {
                return(false);
            }

            var gridLayout = MadTransform.FindChild <MadLevelGridLayout>(panel.transform);

            return(gridLayout != null);
        }
Example #6
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);
    }
#pragma warning disable 429, 162
    private void Unity5Check()
    {
        // generated check
        // ReSharper disable once ConditionIsAlwaysTrueOrFalse
        if ("MadLevelManager" != ("_NAME" + "SPACE_") && "MadLevelManager" != "MadLevelManager")
        {
            return;
        }

        if (Application.isPlaying)
        {
            return;
        }

#if UNITY_EDITOR
        int majorVersion;
        if (int.TryParse(Application.unityVersion.Split('.')[0], out majorVersion))
        {
            if (majorVersion >= 5 && renderMode == RenderMode.Legacy)
            {
                var nonAtlasSprite = MadTransform.FindChild <MadSprite>(transform,
                                                                        (s) => {
                    if (s is MadText)
                    {
                        return(((MadText)s).atlas == null);
                    }
                    else
                    {
                        return(s.inputType == MadSprite.InputType.SingleTexture && MadGameObject.IsActive(s.gameObject));
                    }
                });
                if (nonAtlasSprite != null)
                {
                    bool sw = EditorUtility.DisplayDialog(
                        "Unity 5 Compatibility",
                        "With Unity 5 is recommended to switch to Depth-Based render mode or Legacy mode with atlases only. " +
                        "Please see Unity 5 Compatibility docmentation page for more information. " +
                        "Do you want to switch to Depth-Based mode?\n\n",
                        "Yes (Recommended)", "No");
                    if (sw)
                    {
                        renderMode = RenderMode.DepthBased;
                    }
                }
            }
        }
#endif
    }
Example #8
0
    public static MadLevelGridBullets Create(MadPanel panel) {
        var anchor = MadTransform.CreateChild<MadAnchor>(panel.transform, "Bullets Anchor");

        anchor.mode = MadAnchor.Mode.ScreenAnchor;
        anchor.position = MadAnchor.Position.Bottom;

        var bullets = MadTransform.CreateChild<MadLevelGridBullets>(anchor.transform, "Bullets");
        bullets.transform.localPosition = new Vector3(0, 50, 0);

        var draggable = MadTransform.FindChild<MadDragStopDraggable>(panel.transform, int.MaxValue);
        bullets.draggable = draggable;

        bullets.bulletTextureOff = (Texture2D) AssetDatabase.LoadAssetAtPath(BulletOff, typeof(Texture2D));
        bullets.bulletTextureOn = (Texture2D) AssetDatabase.LoadAssetAtPath(BulletOn, typeof(Texture2D));

        return bullets;
    }
Example #9
0
    private void Upgrade()
    {
        var cam = MadTransform.FindChild <Camera>(transform, (obj) => obj.name == "Camera 2D");

        if (cam != null)
        {
            cam.nearClipPlane = CameraNearClip;
            cam.farClipPlane  = CameraFarClip;
            Debug.Log("Camera 2D clip planes has been updated to recommended values. Please save the scene afterwards.", cam);

#if UNITY_EDITOR
            EditorUtility.SetDirty(cam);
#endif
        }

        SetCurrentVersion();
    }
Example #10
0
    private static void Initialize() {
        var guiRootPrefab = AssetDatabase.LoadAssetAtPath(
            AssetDatabase.GUIDToAssetPath(GUIRootGUID), typeof(GameObject)) as GameObject;
        var loadingScriptPrefab = AssetDatabase.LoadAssetAtPath(
            AssetDatabase.GUIDToAssetPath(LoadingScriptGUID), typeof (GameObject)) as GameObject;

        var guiRootInstance = Object.Instantiate(guiRootPrefab) as GameObject;
        var loadingScriptInstance = Object.Instantiate(loadingScriptPrefab) as GameObject;

        guiRootInstance.name = guiRootPrefab.name;
        loadingScriptInstance.name = loadingScriptPrefab.name;

        PrefabUtility.DisconnectPrefabInstance(guiRootInstance);
        PrefabUtility.DisconnectPrefabInstance(loadingScriptInstance);

        var loadingBar = MadTransform.FindChild<MadSprite>(guiRootInstance.transform, sprite => sprite.name == "bar").gameObject;
        var loadingText = MadTransform.FindChild<MadText>(guiRootInstance.transform, text => text.name == "loading text").gameObject;
        var loadedText = MadTransform.FindChild<MadText>(guiRootInstance.transform, text => text.name == "loaded text").gameObject;
        var pressAnywhereText = MadTransform.FindChild<MadText>(guiRootInstance.transform, text => text.name == "press anywhere text").gameObject;

        var loadingScreen = loadingScriptInstance.GetComponent<LoadingScreen>();

        loadingScreen.loadingBar = loadingBar;

        loadingScreen.changeDisable.Clear();
        loadingScreen.changeDisable.Add(loadingText);

        loadingScreen.changeEnable.Clear();
        loadingScreen.changeEnable.Add(loadedText);
        loadingScreen.changeEnable.Add(pressAnywhereText);

        MadGameObject.SetActive(loadedText, false);
        MadGameObject.SetActive(pressAnywhereText, false);

        new GameObject("_mlm_ignore");
    }
    void Build()
    {
        List <MadLevelIcon> allIcons = new List <MadLevelIcon>();

        allIcons.AddRange(MadTransform.FindChildren <MadLevelIcon>(transform));

        int     levelCount    = currentConfiguration.LevelCount(MadLevel.Type.Level, configurationGroup);
        Vector2 currentOffset = Vector2.zero;

        MadLevelIcon previousIcon = null;

        // find out min and max depth
        int min, max;

        iconTemplate.MinMaxDepthRecursively(out min, out max);
        const string name = "level {0:D3}";

        HashSet <MadLevelIcon> activeIcons = new HashSet <MadLevelIcon>();

        for (int levelIndex = 0; levelIndex < levelCount; ++levelIndex)
        {
            MadLevelIcon levelIcon = MadTransform.FindChild <MadLevelIcon>(
                draggable.transform, (ic) => ic.levelIndex == levelIndex, 0);
            bool newInstance = levelIcon == null;

            // create new icon instance if it's not exists
            if (newInstance)
            {
                levelIcon = CreateIcon(draggable.transform, string.Format(name, levelIndex + 1), iconTemplate);

                // position & scale
                levelIcon.pivotPoint           = MadSprite.PivotPoint.Center;
                levelIcon.transform.localScale = Vector3.one;

                do
                {
                    levelIcon.transform.localPosition = currentOffset;
                    currentOffset += offset;
                } while (Collides(levelIcon, allIcons));

                allIcons.Add(levelIcon);
            }

            // make it active if deactivated
            if (!MadGameObject.IsActive(levelIcon.gameObject))
            {
                MadGameObject.SetActive(levelIcon.gameObject, true);
            }

            // setup level properties
            levelIcon.levelGroup            = configurationGroup;
            levelIcon.levelIndex            = levelIndex;
            levelIcon.configuration         = currentConfiguration;
            levelIcon.hasLevelConfiguration = true;

            // set level number if exists
            if (levelIcon.levelNumber != null)
            {
                levelIcon.levelNumber.text = GetEnumerationValue(levelIndex);
            }

            // level unlock if set
            if (previousIcon != null)
            {
                if (newInstance)
                {
                    previousIcon.unlockOnComplete.Add(levelIcon);
                }
            }
            else
            {
                levelIcon.locked = false;
            }

            if (!Application.isPlaying || !MadLevelProfile.IsLockedSet(levelIcon.level.name))
            {
                levelIcon.locked = levelIcon.level.lockedByDefault;
            }

            previousIcon = levelIcon;

            activeIcons.Add(levelIcon);
        }

        BuildBackgroundTexture();

        DeactivateAllOther(activeIcons);
    }
Example #12
0
    // builds level icons that are absent now
    void Build()
    {
        // create or get a draggable
        draggable = MadTransform.GetOrCreateChild <MadDragStopDraggable>(transform, "Draggable");

        draggable.dragStopCallback = (index) => {
            pageCurrentIndex = index;
        };

        float startX = -pixelsWidth / 2;
        float startY = pixelsHeight / 2;

        float dx = pixelsWidth / (gridWidth + 1);
        float dy = -pixelsHeight / (gridHeight + 1);

        int levelNumber = 1;

        MadLevelIcon previousIcon = null;

        int levelCount = configuration.LevelCount(MadLevel.Type.Level);
        int levelIndex = 0;

        int pageIndex = 0;

        while (levelIndex < levelCount)
        {
            Transform page = MadTransform.FindChild <Transform>(draggable.transform, (t) => t.name == "Page " + (pageIndex + 1));
            bool      createPageInstance = page == null;

            if (createPageInstance)
            {
                page = MadTransform.CreateChild <Transform>(draggable.transform, "Page " + (pageIndex + 1));
            }

            if (createPageInstance || generate)
            {
                page.localPosition = new Vector3(pagesXOffset * pageIndex, 0, 0);
            }


            for (int y = 1; y <= gridHeight && levelIndex < levelCount; ++y)
            {
                for (int x = 1; x <= gridWidth && levelIndex < levelCount; ++x, levelIndex++)
                {
                    // update info: in previous versions page was nested directly under draggable
                    // now they should be placed inside "Page X" transforms
                    MadLevelIcon levelIcon;

                    // look directly under Draggable
                    levelIcon = MadTransform.FindChild <MadLevelIcon>(
                        draggable.transform, (ic) => ic.levelIndex == levelIndex, 0);
                    if (levelIcon != null)
                    {
                        // move to page
                        levelIcon.transform.parent = page;
                    }
                    else
                    {
                        // find under the page
                        levelIcon = MadTransform.FindChild <MadLevelIcon>(
                            page.transform, (ic) => ic.levelIndex == levelIndex, 0);
                    }

                    bool createNewInstance = levelIcon == null;
                    var  level             = configuration.GetLevel(MadLevel.Type.Level, levelIndex);

                    if (createNewInstance)
                    {
                        levelIcon = MadTransform.CreateChild(
                            page.transform, level.name, iconTemplate);
                    }
                    else
                    {
                        levelIcon.name = level.name;
                    }

                    levelIcon.gameObject.hideFlags = generate ? HideFlags.HideInHierarchy : 0;

                    if (!MadGameObject.IsActive(levelIcon.gameObject))
                    {
                        MadGameObject.SetActive(levelIcon.gameObject, true);
                    }

                    levelIcon.levelIndex            = levelIndex;
                    levelIcon.configuration         = configuration;
                    levelIcon.hasLevelConfiguration = true;

                    if (generate || createNewInstance)
                    {
                        levelIcon.pivotPoint = MadSprite.PivotPoint.Center;

                        levelIcon.transform.localPosition =
                            new Vector3(startX + dx * x + iconOffset.x, startY + dy * y + iconOffset.y, 0);

                        levelIcon.transform.localScale = new Vector3(iconScale.x, iconScale.y, 1);

                        if (levelIcon.levelNumber != null)
                        {
                            levelIcon.levelNumber.text = levelNumber.ToString();
                        }
                    }

                    if (previousIcon != null)
                    {
                        if (createNewInstance)
                        {
                            previousIcon.unlockOnComplete.Add(levelIcon);
                        }
                    }
                    else
                    {
                        if (generate)
                        {
                            levelIcon.locked = false;
                        }
                    }

                    previousIcon = levelIcon;
                    levelNumber++;
                }
            }

            pageIndex++;
        }

        BuildSlideIcons();
        BuildDragging(draggable, (int)Mathf.Ceil((float)levelCount / (gridWidth * gridHeight)));

        // enable/disable selection based on hide settings
        var sprites = GetComponentsInChildren <MadSprite>();

        foreach (var sprite in sprites)
        {
            sprite.editorSelectable = !generate;
        }
    }
Example #13
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 #14
0
    // builds level icons that are absent now
    private void Build(bool forceDelete)
    {
        // create or get a draggable
        draggable = MadTransform.GetOrCreateChild <MadDragStopDraggable>(transform, "Draggable");

        draggable.dragStopCallback = OnDragStopCallback;

        float startX = -pixelsWidth / 2;
        float startY = pixelsHeight / 2;

        float dx = pixelsWidth / (gridWidth + 1);
        float dy = -pixelsHeight / (gridHeight + 1);

        MadLevelIcon previousIcon = null;

        int levelCount = currentConfiguration.LevelCount(MadLevel.Type.Level, configurationGroup);
        int levelIndex = 0;

        int pageIndex = 0;

        while (levelIndex < levelCount)
        {
            Transform page = MadTransform.FindChild <Transform>(draggable.transform,
                                                                (t) => t.name == "Page " + (pageIndex + 1));
            bool createPageInstance = page == null;

            if (createPageInstance)
            {
                page           = MadTransform.CreateChild <Transform>(draggable.transform, "Page " + (pageIndex + 1));
                page.hideFlags = generate && hideManagedObjects ? HideFlags.HideInHierarchy : 0;
            }

            Transform pageAnchor = MadTransform.FindChild <Transform>(draggable.transform,
                                                                      (t) => t.name == "Anchor " + (pageIndex + 1));
            if (pageAnchor == null)
            {
                pageAnchor = MadTransform.CreateChild <Transform>(draggable.transform, "Anchor " + (pageIndex + 1));
                pageAnchor.gameObject.AddComponent <MadFollow>();
            }

            var followPage = pageAnchor.GetComponent <MadFollow>();
            followPage.followTransform = page;

            if (createPageInstance || generate)
            {
                switch (pagingMethod)
                {
                case PagingMethod.HorizontalSimple:
                    page.localPosition = ComputePageOffsetHoriz(pageIndex);
                    break;

                case PagingMethod.VerticalSimple:
                    page.localPosition = ComputePageOffsetVert(pageIndex);
                    break;

                case PagingMethod.HorizontalZoom:
                    page.localPosition = ComputePageOffsetHoriz(pageIndex);
                    break;

                case PagingMethod.VerticalZoom:
                    page.localPosition = ComputePageOffsetVert(pageIndex);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            int  levelPageIndex = 0;
            bool stop           = false;
            for (int y = 1; y <= gridHeight && levelIndex < levelCount; ++y)
            {
                if (stop)
                {
                    break;
                }

                for (int x = 1; x <= gridWidth && levelIndex < levelCount; ++x, levelIndex++, levelPageIndex++)
                {
                    if (limitLevelsPerPage && generate && levelPageIndex == levelsPerPage)
                    {
                        stop = true;
                        break;
                    }

                    // update info: in previous versions page was nested directly under draggable
                    // now they should be placed inside "Page X" transforms
                    MadLevelIcon levelIcon = null;

                    if (!forceDelete)
                    {
                        // look directly under Draggable
                        levelIcon = MadTransform.FindChild <MadLevelIcon>(
                            draggable.transform, (ic) => ic.levelIndex == levelIndex, 0);
                        if (levelIcon != null)
                        {
                            // move to page
                            levelIcon.transform.parent = page;
                        }
                        else
                        {
                            // find under the page
                            levelIcon = MadTransform.FindChild <MadLevelIcon>(
                                page.transform, (ic) => ic.levelIndex == levelIndex, 0);
                        }
                    }

                    var  level             = currentConfiguration.GetLevel(MadLevel.Type.Level, configurationGroup, levelIndex);
                    bool createNewInstance = levelIcon == null;

                    if (createNewInstance)
                    {
                        levelIcon = CreateIcon(
                            page.transform, level.name, iconTemplate);
                    }
                    else
                    {
                        levelIcon.name = level.name;
                    }

                    levelIcon.gameObject.hideFlags = generate && hideManagedObjects ? HideFlags.HideInHierarchy : 0;

                    levelIcon.levelGroup            = configurationGroup;
                    levelIcon.levelIndex            = levelIndex;
                    levelIcon.configuration         = currentConfiguration;
                    levelIcon.hasLevelConfiguration = true;

                    if (!MadGameObject.IsActive(levelIcon.gameObject))
                    {
                        MadGameObject.SetActive(levelIcon.gameObject, true);
                    }
                    else
                    {
                        // re-enable icon to reload its properties
                        MadGameObject.SetActive(levelIcon.gameObject, false);
                        MadGameObject.SetActive(levelIcon.gameObject, true);
                    }

                    if (generate || createNewInstance)
                    {
                        levelIcon.pivotPoint = MadSprite.PivotPoint.Center;

                        if (!generate)
                        {
                            levelIcon.transform.localPosition =
                                new Vector3(startX + dx * x + iconOffset.x, startY + dy * y + iconOffset.y, 0);
                        }
                        else
                        {
                            levelIcon.transform.localPosition = IconGeneratedPosition(levelIndex, levelCount, x - 1,
                                                                                      y - 1);
                        }

                        levelIcon.transform.localScale = new Vector3(iconScale.x, iconScale.y, 1);

                        if (levelIcon.levelNumber != null)
                        {
                            levelIcon.levelNumber.text = GetEnumerationValue(levelIndex);
                        }
                    }

                    if (previousIcon != null)
                    {
                        if (createNewInstance)
                        {
                            previousIcon.unlockOnComplete.Add(levelIcon);
                        }
                    }

                    if (!Application.isPlaying || !MadLevelProfile.IsLockedSet(level.name))
                    {
                        levelIcon.locked = levelIcon.level.lockedByDefault;
                    }

                    previousIcon = levelIcon;
                }
            }

            pageIndex++;
        }

        BuildSlideIcons();
        BuildDragging();

        // enable/disable selection based on hide settings
        var sprites = GetComponentsInChildren <MadSprite>();

        foreach (var sprite in sprites)
        {
            sprite.editorSelectable = !generate;
        }

#if UNITY_EDITOR
        EditorApplication.delayCall += () => EditorUtility.SetDirty(this);
#endif
    }
Example #15
0
    void Build()
    {
        int     levelCount    = configuration.LevelCount(MadLevel.Type.Level);
        Vector2 currentOffset = Vector2.zero;

        MadLevelIcon previousIcon = null;

        // find out min and max depth
        int min, max;

        iconTemplate.MinMaxDepthRecursively(out min, out max);
        int depthDiff = (max - min) + 1;

        const string name = "level {0:D3}";

        for (int levelIndex = 0; levelIndex < levelCount; ++levelIndex)
        {
            MadLevelIcon levelIcon = MadTransform.FindChild <MadLevelIcon>(
                draggable.transform, (ic) => ic.levelIndex == levelIndex, 0);
            bool newInstance = levelIcon == null;

            // create new icon instance if it's not exists
            if (newInstance)
            {
                levelIcon = MadTransform.CreateChild(
                    draggable.transform, string.Format(name, levelIndex + 1), iconTemplate);

                // adjust gui depth for each icon
                levelIcon.guiDepth += levelIndex * depthDiff;
                var sprites = MadTransform.FindChildren <MadSprite>(levelIcon.transform);
                foreach (var sprite in sprites)
                {
                    sprite.guiDepth += levelIndex * depthDiff;
                }

                // position & scale
                levelIcon.pivotPoint = MadSprite.PivotPoint.Center;
                levelIcon.transform.localPosition = currentOffset;
                currentOffset += offset;

                levelIcon.transform.localScale = Vector3.one;
            }

            // make it active if deactivated
            if (!MadGameObject.IsActive(levelIcon.gameObject))
            {
                MadGameObject.SetActive(levelIcon.gameObject, true);
            }

            // setup level properties
            levelIcon.levelIndex            = levelIndex;
            levelIcon.configuration         = configuration;
            levelIcon.hasLevelConfiguration = true;

            // set level number if exists
            if (levelIcon.levelNumber != null)
            {
                levelIcon.levelNumber.text = (levelIndex + 1).ToString();
            }

            // level unlock if set
            if (previousIcon != null)
            {
                if (newInstance)
                {
                    previousIcon.unlockOnComplete.Add(levelIcon);
                }
            }
            else
            {
                levelIcon.locked = false;
            }

            previousIcon = levelIcon;
        }

        BuildBackgroundTexture();
    }