Exemple #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);
    }
Exemple #2
0
    private void ClearSlide(string anchorName)
    {
        MadAnchor slideAnchor = MadTransform.FindChildWithName <MadAnchor>(transform, anchorName);

        if (slideAnchor != null)
        {
            DestroyImmediate(slideAnchor.gameObject);
        }
    }
    private void ResizeDragAreaToBackground()
    {
        var background = MadTransform.FindChildWithName <MadSprite>(script.transform, "background");

        MadUndo.RecordObject2(script, "Resize Drag Area");

        Rect spriteBounds = background.GetTransformedBounds();

        script.dragBounds = new Bounds(spriteBounds.center, new Vector2(spriteBounds.xMax - spriteBounds.xMin, spriteBounds.yMax - spriteBounds.yMin));

        EditorUtility.SetDirty(script);
    }
 void BuildBackgroundTexture()
 {
     if (backgroundTexture != null)
     {
         var background = MadTransform.GetOrCreateChild <MadSprite>(draggable.transform, "background");
         background.texture  = backgroundTexture;
         background.guiDepth = -1;
     }
     else
     {
         var background = MadTransform.FindChildWithName <MadSprite>(draggable.transform, "background");
         if (background != null)
         {
             DestroyImmediate(background.gameObject);
         }
     }
 }
    private bool HasBackground()
    {
        var background = MadTransform.FindChildWithName <MadSprite>(script.transform, "background");

        return(background != null);
    }