Пример #1
0
    public override void gaxb_init()
    {
        base.gaxb_init ();

        if (title == null) {
            gameObject.name = "<Slider/>";
        }

        slider = gameObject.AddComponent<Slider> ();

        if (fillResourcePath != null) {
            fill = new PUImage (fillResourcePath, Color.white);
            fill.SetFrame (0, 0, 0, 0, 0.5f, 0.5f, "stretch,stretch");
            fill.LoadIntoPUGameObject (this);
        }

        handle = new PUImage (handleResourcePath, Color.white);
        handle.SetFrame (0, 0, handleSize.Value.x, handleSize.Value.y, 0.5f, 0.5f, "stretch,stretch");
        if (handleResourcePath == null) {
            handle.color = Color.clear;
        }
        handle.LoadIntoPUGameObject (this);

        if (onValueChanged != null) {
            slider.onValueChanged.AddListener ((v) => {
                NotificationCenter.postNotification (Scope (), this.onValueChanged, NotificationCenter.Args("sender", this, "value", v));
            });
        }

        slider.targetGraphic = handle.image;
        slider.handleRect = handle.rectTransform;
        if (fill != null) {
            slider.fillRect = fill.rectTransform;
        }

        if (direction == PlanetUnity2.SliderDirection.BottomToTop) {
            slider.direction = Slider.Direction.BottomToTop;
        } else if (direction == PlanetUnity2.SliderDirection.TopToBottom) {
            slider.direction = Slider.Direction.TopToBottom;
        } else if (direction == PlanetUnity2.SliderDirection.LeftToRight) {
            slider.direction = Slider.Direction.LeftToRight;
        } else if (direction == PlanetUnity2.SliderDirection.RightToLeft) {
            slider.direction = Slider.Direction.RightToLeft;
        }

        if (minValue != null) {
            slider.minValue = (float)minValue;
        }

        if (maxValue != null) {
            slider.maxValue = (float)maxValue;
        }

        handle.rectTransform.sizeDelta = new Vector2 (handleSize.Value.x, handleSize.Value.y);
    }
Пример #2
0
    public override void gaxb_init()
    {
        base.gaxb_init();

        if (title == null)
        {
            gameObject.name = "<Slider/>";
        }

        slider = gameObject.AddComponent <Slider> ();

        if (fillResourcePath != null)
        {
            fill = new PUImage(fillResourcePath, Color.white);
            fill.SetFrame(0, 0, 0, 0, 0.5f, 0.5f, "stretch,stretch");
            fill.LoadIntoPUGameObject(this);
        }

        handle = new PUImage(handleResourcePath, Color.white);
        handle.SetFrame(0, 0, handleSize.Value.x, handleSize.Value.y, 0.5f, 0.5f, "stretch,stretch");
        if (handleResourcePath == null)
        {
            handle.color = Color.clear;
        }
        handle.LoadIntoPUGameObject(this);

        if (onValueChanged != null)
        {
            slider.onValueChanged.AddListener((v) => {
                NotificationCenter.postNotification(Scope(), this.onValueChanged, NotificationCenter.Args("sender", this, "value", v));
            });
        }

        slider.targetGraphic = handle.image;
        slider.handleRect    = handle.rectTransform;
        if (fill != null)
        {
            slider.fillRect = fill.rectTransform;
        }

        if (direction == PlanetUnity2.SliderDirection.BottomToTop)
        {
            slider.direction = Slider.Direction.BottomToTop;
        }
        else if (direction == PlanetUnity2.SliderDirection.TopToBottom)
        {
            slider.direction = Slider.Direction.TopToBottom;
        }
        else if (direction == PlanetUnity2.SliderDirection.LeftToRight)
        {
            slider.direction = Slider.Direction.LeftToRight;
        }
        else if (direction == PlanetUnity2.SliderDirection.RightToLeft)
        {
            slider.direction = Slider.Direction.RightToLeft;
        }

        if (minValue != null)
        {
            slider.minValue = (float)minValue;
        }

        if (maxValue != null)
        {
            slider.maxValue = (float)maxValue;
        }

        handle.rectTransform.sizeDelta = new Vector2(handleSize.Value.x, handleSize.Value.y);
    }