Beispiel #1
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;
    }
Beispiel #2
0
    // ===========================================================
    // Methods
    // ===========================================================

    void OnGUI()
    {
        MadGUI.Info("This tool initialized your scene for GUI drawing. Please choose root object name and layer "
                    + "on which GUI will be painted.");

        rootObjectName = EditorGUILayout.TextField("Root Name", rootObjectName);
        layer          = EditorGUILayout.LayerField("Layer", layer);

        OnFormGUI();

        if (GUILayout.Button("Create"))
        {
            var  panel  = MadPanel.UniqueOrNull();
            bool doInit = true;
            if (panel != null)
            {
                doInit = EditorUtility.DisplayDialog("Scene initialized", "Scene looks like it is already initialized. "
                                                     + "Are you sure that you want to continue?", "Yes", "No");
            }

            if (doInit)
            {
                root = Init(rootObjectName, layer, hideInvisibleSprites, depthBasedRenderMode);
                AfterCreate(root);
            }
        }
    }
Beispiel #3
0
    protected override void AfterCreate(MadRootNode root)
    {
        var madLevelRoot = root.gameObject.AddComponent <MadLevelRoot>();

        madLevelRoot.SetCurrentVersion();

        MadLevelIcon icon;
        MadSprite    slideLeft, slideRight;

        switch (layout)
        {
        case Layout.Grid:
            InitTemplates(root, out icon, out slideLeft, out slideRight);
            CreateGrid(root, icon, slideLeft, slideRight);
            break;

        case Layout.Free:
            InitTemplates(root, out icon, out slideLeft, out slideRight);
            CreateFree(root, icon);
            break;

        case Layout.None:
            // do not add anything on the scene
            break;

        default:
            Debug.LogError("Unknown layout: " + layout);
            break;
        }
    }
    protected override void AfterCreate(MadRootNode root) {
        var madLevelRoot = root.gameObject.AddComponent<MadLevelRoot>();
        madLevelRoot.SetCurrentVersion();

        MadLevelIcon icon;
        MadSprite slideLeft, slideRight;

        switch (layout) {
            case Layout.Grid:
                InitTemplates(root, out icon, out slideLeft, out slideRight);
                CreateGrid(root, icon, slideLeft, slideRight);
                break;
            case Layout.Free:
                InitTemplates(root, out icon, out slideLeft, out slideRight);
                CreateFree(root, icon);
                break;
            case Layout.None:
                // do not add anything on the scene
                break;
            default:
                Debug.LogError("Unknown layout: " + layout);
                break;
        }

    }
Beispiel #5
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;
    }
Beispiel #6
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;
    }
Beispiel #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;
    }
Beispiel #8
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);
    }
Beispiel #9
0
 // ===========================================================
 // Methods
 // ===========================================================
 
 void OnGUI() {
     MadGUI.Info("This tool initialized your scene for GUI drawing. Please choose root object name and layer "
         + "on which GUI will be painted.");
 
     rootObjectName = EditorGUILayout.TextField("Root Name", rootObjectName);
     layer = EditorGUILayout.LayerField("Layer", layer);
     
     OnFormGUI();
     
     if (GUILayout.Button("Create")) {
         var panel = MadPanel.UniqueOrNull();
         bool doInit = true;
         if (panel != null) {
             doInit = EditorUtility.DisplayDialog("Scene initialized", "Scene looks like it is already initialized. "
                 + "Are you sure that you want to continue?", "Yes", "No");
         }
     
         if (doInit) {
             root = Init(rootObjectName, layer);
             AfterCreate(root);
         }
     }
 }
Beispiel #10
0
    protected override void AfterCreate(MadRootNode root)
    {
        root.gameObject.AddComponent <MadLevelRoot>();

        MadLevelIcon icon;
        MadSprite    slideLeft, slideRight;

        InitTemplates(root, out icon, out slideLeft, out slideRight);

        switch (layout)
        {
        case Layout.Grid:
            CreateGrid(root, icon, slideLeft, slideRight);
            break;

        case Layout.Free:
            CreateFree(root, icon);
            break;

        default:
            Debug.LogError("Unknown layout: " + layout);
            break;
        }
    }
Beispiel #11
0
 protected virtual void AfterCreate(MadRootNode root)
 {
 }
Beispiel #12
0
 protected virtual void Start()
 {
     root          = MadTransform.FindParent <MadRootNode>(transform);
     cachedCamPos  = cameraPos;
     lastTouchTime = -1000; // prevent touch time on start
 }
Beispiel #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);
    }
Beispiel #14
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);
    }
Beispiel #15
0
 protected virtual void AfterCreate(MadRootNode root) {}