public void Initialize()
        {
            //Set slidable
            //nameTextMesh = gameObject.GetComponentInChildren<TextMesh>();
            slidable = gameObject.GetComponentInChildren <GuiSlidable>();

            //Find existing GUI node
            GuiNode node = gameObject.GetComponentInChildren <GuiNode>(true);

            if (node == null)
            {
                return;
            }

            //Link this component to the node
            GuiBindInData inData      = new GuiBindInData(null, null);
            GuiBindData   guiBindData = GuiNode.Connect(this.gameObject, inData);
            string        trackerID   = "ScrollBar" + UIElement.GetNewTrackerID();

            guiBindData.AddTracker(trackerID, node);

            //Set delegate function
            IGuiOnchangeFloat tryfind = guiBindData.GetTrackerEvent <IGuiOnchangeFloat>(trackerID);

            if (tryfind == null)
            {
                return;
            }
            tryfind.onchange = new GuiNode.OnFloatFunc(SliderMoved);

            //Set default step
            SliderStep        = 0.01f;
            AllowScroll       = true;
            _scrollMultiplier = 1;
        }
Exemple #2
0
        public void Initialize()
        {
            //Set TextMesh, slidable and textframe
            nameTextMesh = gameObject.GetComponentInChildren <TextMesh>();
            slidable     = gameObject.GetComponentInChildren <GuiSlidable>();
            _display     = gameObject.GetComponentInChildren <UITextFrame>();
            UpdateDisplayValue();

            //Find existing GUI node
            GuiNode node = gameObject.GetComponentInChildren <GuiNode>(true);

            if (node == null)
            {
                return;
            }

            //Link this component to the node
            GuiBindInData inData      = new GuiBindInData(null, null);
            GuiBindData   guiBindData = GuiNode.Connect(this.gameObject, inData);
            string        trackerID   = "Slider" + UIElement.GetNewTrackerID();

            guiBindData.AddTracker(trackerID, node);

            //Set delegate function
            IGuiOnchangeFloat tryfind = guiBindData.GetTrackerEvent <IGuiOnchangeFloat>(trackerID);

            if (tryfind == null)
            {
                return;
            }
            tryfind.onchange = new GuiNode.OnFloatFunc(SliderMoved);

            //Text resizing
            DefLineSize      = 200f;
            OriginalTextSize = nameTextMesh.transform.localScale;
            AutoTextResize   = true;
        }