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

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