コード例 #1
0
 private void Start()
 {
     if (setTipOnStart)
     {
         SOTip tip = tips[Random.Range(0, tips.Length)];
         SetTip(tip);
     }
 }
コード例 #2
0
    public void SetTip(SOTip tip)
    {
        ResetImagePasePanel();

        if (tip.IsLocalisedText)
        {
            tipsText.text = Localization.GetString(tip.TipText);
        }
        else
        {
            tipsText.text = tip.TipText;
        }

        //
        tipsImagePlace.gameObject.SetActive(true);

        if (tip.AnimatedImageOriginal != null)
        {
            SetAnimatedImage(tip.AnimatedImageOriginal);
        }
        else if (tip.Images.Length > 0)
        {
            foreach (var img in tip.Images)
            {
                SetImage(img, tip.Direction);
            }
            LayoutRebuilder.MarkLayoutForRebuild(tipsImagePlace);
        }
        else
        {
            tipsImagePlace.gameObject.SetActive(false);
        }


        if (tip.Direction == SOTip.Directions.HORISONTAL)
        {
            var layout = horisontalLayout;
            ResetTipPanelLayout(layout);

            layout.childAlignment         = TextAnchor.MiddleCenter;
            layout.spacing                = 20;
            layout.padding.left           = 100;
            layout.padding.right          = 100;
            layout.childControlHeight     = true;
            layout.childControlWidth      = true;
            layout.childForceExpandHeight = true;
            layout.childForceExpandWidth  = true;

            tipsText.alignment = TextAlignmentOptions.Midline;
        }
        else
        {
            var layout = vertialLayout;
            ResetTipPanelLayout(layout);

            layout.childAlignment         = TextAnchor.MiddleCenter;
            layout.spacing                = 10;
            layout.childControlHeight     = true;
            layout.childControlWidth      = true;
            layout.childForceExpandHeight = true;
            layout.childForceExpandWidth  = true;

            tipsText.alignment = TextAlignmentOptions.Midline;
        }
    }