示例#1
0
 public void UpdateColors()
 {
     foreach (GameObject digit in digits)
     {
         OdometerDigit od = digit.GetComponent <OdometerDigit> ();
         if (!od.overrideColors)
         {
             od.backBackgroundColor = backBackgroundColor;
             od.fontColor           = fontColor;
             od.backgroundColor     = backgroundColor;
             od.UpdateColors();
         }
     }
 }
示例#2
0
    IEnumerator SaveSkin()
    {
        SkinElement currentSkinElement = new SkinElement();

        currentSkinElement.id = skinTagId;

        currentSkinElement.xCoord     = transform.localPosition.x.ToString();
        currentSkinElement.yCoord     = transform.localPosition.y.ToString();
        currentSkinElement.backsprite = "";
        currentSkinElement.tagname    = skinTag;
        currentSkinElement.foresprite = "";

        if (gameObject.GetComponent <Odometer>() != null)
        {
            prizeODO = gameObject.GetComponent <Odometer>();
            currentSkinElement.backcolor = ColorToHex(prizeODO.backBackgroundColor);
            currentSkinElement.forecolor = ColorToHex(prizeODO.backgroundColor);
            currentSkinElement.textcolor = ColorToHex(prizeODO.fontColor);
        }
        if (gameObject.GetComponent <OdometerDigit>() != null)
        {
            PrizeODODollarSign           = gameObject.GetComponent <OdometerDigit>();
            currentSkinElement.backcolor = ColorToHex(PrizeODODollarSign.backBackgroundColor);
            currentSkinElement.forecolor = ColorToHex(PrizeODODollarSign.backgroundColor);
            currentSkinElement.textcolor = ColorToHex(PrizeODODollarSign.fontColor);
        }
        if (gameObject.GetComponent <UILabel>() != null)
        {
            UILabel currentLabel = gameObject.GetComponent <UILabel>();
            currentSkinElement.bordercolor = ColorToHex(currentLabel.effectColor);
            currentSkinElement.textcolor   = ColorToHex(currentLabel.color);
        }
        if (gameObject.GetComponent <TextMeshPro>() != null)
        {
            TextMeshPro currentLabel = gameObject.GetComponent <TextMeshPro>();
            //currentSkinElement.bordercolor = ColorToHex(currentLabel.effectColor);
            currentLabel.faceColor = currentLabel.color;
        }

        if (gameObject.name == ("Camera"))
        {
            currentSkinElement.backcolor = ColorToHex(gameObject.GetComponent <Camera>().backgroundColor);
        }
        if (bg != null)
        {
            currentSkinElement.backcolor = ColorToHex(bg.color);
        }
        if (bordercolor != null)
        {
            currentSkinElement.bordercolor = ColorToHex(bordercolor.color);
        }
        if (gameObject.GetComponent <UILabel>() != null)
        {
        }
        if (txtcolor != null)
        {
            currentSkinElement.textcolor = ColorToHex(txtcolor.color);
        }

        if (bgsprite != null)
        {
            currentSkinElement.width  = bgsprite.width.ToString();
            currentSkinElement.height = bgsprite.height.ToString();
        }

        var form = new WWWForm();

        form.AddField("action", "SaveSkinSettings");
        form.AddField("appVersion", Application.version);
        form.AddField("macAddress", DisplayManager.displayManager.macAddress);
        form.AddField("skinData", JsonUtility.ToJson(currentSkinElement));

        // Start a download of the given URL
        WWW www = new WWW(DisplayManager.displayManager.url, form);

        // Wait for download to complete
        yield return(www);

        Debug.Log(www.text);
    }
示例#3
0
    public void Skinit()
    {
        SkinElement SE = DisplayManager.displayManager.currentScene.sceneSkin.skinData.Find(se => (se.tagname.Equals(skinTag)));

        if (SE)
        {
            this.skinTagId = SE.id;
            this.skinId    = DisplayManager.displayManager.currentScene.sceneSkin.skinID;
            this.skinName  = DisplayManager.displayManager.currentScene.sceneSkin.skinName;
            if (SE != null)
            {
                if (fg != null)
                {
                    fg.color = HexToColor(SE.forecolor);
                }

                if (gameObject.GetComponent <Odometer>() != null)
                {
                    prizeODO = gameObject.GetComponent <Odometer>();
                    prizeODO.backBackgroundColor = HexToColor(SE.backcolor);
                    prizeODO.backgroundColor     = HexToColor(SE.forecolor);
                    prizeODO.fontColor           = HexToColor(SE.textcolor);
                }
                if (gameObject.GetComponent <OdometerDigit>() != null)
                {
                    PrizeODODollarSign = gameObject.GetComponent <OdometerDigit>();
                    PrizeODODollarSign.backBackgroundColor = HexToColor(SE.backcolor);
                    PrizeODODollarSign.backgroundColor     = HexToColor(SE.forecolor);
                    PrizeODODollarSign.fontColor           = HexToColor(SE.textcolor);
                }
                if (gameObject.GetComponent <UILabel>() != null)
                {
                    UILabel currentLabel = gameObject.GetComponent <UILabel>();
                    currentLabel.effectColor = HexToColor(SE.bordercolor);
                    currentLabel.color       = HexToColor(SE.textcolor);
                }
                if (gameObject.GetComponent <TextMeshPro>() != null)
                {
                    TextMeshPro currentLabel = gameObject.GetComponent <TextMeshPro>();
                    currentLabel.color = HexToColor(SE.textcolor);
                }
                if (gameObject.name == ("Camera"))
                {
                    gameObject.GetComponent <Camera>().backgroundColor = HexToColor(SE.backcolor);
                }
                if (bg != null)
                {
                    bg.color = HexToColor(SE.backcolor);
                }
                if (bordercolor != null)
                {
                    bordercolor.color = HexToColor(SE.bordercolor);
                }
                if (gameObject.GetComponent <UILabel>() != null)
                {
                    if (bordercolor == null)
                    {
                        txtcolor.effectStyle = UILabel.Effect.Outline;
                        txtcolor.effectColor = HexToColor(SE.bordercolor);
                    }
                }
                if (txtcolor != null)
                {
                    txtcolor.color = HexToColor(SE.textcolor);
                }
                if (txtColorTM)
                {
                    txtColorTM.color = HexToColor(SE.textcolor);
                }
                if (bgsprite != null)
                {
                    if (skinTag.Equals("Logo"))
                    {
                        bgsprite.atlas = GameObject.FindGameObjectWithTag("Skin").GetComponent <UIAtlas>();
                    }

                    if (SE.backsprite.Equals("DefaultLogo"))
                    {
                        bgsprite.spriteName = DisplayManager.displayManager.displayData.DefaultLogo;
                    }
                    else
                    {
                        bgsprite.spriteName = SE.backsprite;
                    }
                    int  number;
                    bool result = Int32.TryParse(SE.width, out number);
                    if (result)
                    {
                        bgsprite.width = int.Parse(SE.width);
                    }
                    else
                    {
                        Debug.Log("Couldn't parse bgsprite width:" + SE.tagname);
                    }
                    result = Int32.TryParse(SE.height, out number);
                    if (result)
                    {
                        bgsprite.height = int.Parse(SE.height);
                    }
                    else
                    {
                        Debug.Log("Couldn't parse bgsprite height:" + SE.tagname);
                    }
                }
                if (!string.IsNullOrEmpty(SE.xCoord) && !string.IsNullOrEmpty(SE.yCoord))
                {
                    Vector3 temp = new Vector3(float.Parse(SE.xCoord), float.Parse(SE.yCoord), 0);
                    transform.localPosition = temp;
                }
            }
            else
            {
                //Debug.Log("Can't Find:" +skinTag);
            }
        }
    }
示例#4
0
    // Use this for initialization
    void Start()
    {
        border = transform.Find("Border").gameObject;
        //	numDigits = (int)(Mathf.Floor (Mathf.Log10 (maxValue) + 1));
        numDigits = maxValue.ToString().Length;
        if (useGrid)
        {
            grid = transform.Find("DigitGrid").GetComponent <UIGrid> ();

            if (autoSize)
            {
                grid.cellWidth  = digitHeight * heightRatio;
                grid.cellHeight = digitHeight;
            }
            grid.enabled = true;
            if (autoPopulate)
            {
                for (int i = 0; i < numDigits; i++)
                {
                    GameObject digit = Instantiate(digitPrefab, Vector3.zero, Quaternion.identity) as GameObject;
                    digit.transform.parent     = grid.transform;
                    digit.transform.localScale = Vector3.one;
                    digit.name = "Digit" + i;
                }
            }

            if (autoSize)
            {
                foreach (Transform child in grid.transform)
                {
                    if (child.gameObject.GetComponent <OdometerDigit> () != null)
                    {
                        OdometerDigit d = child.GetComponent <OdometerDigit> ();
                        d.GetComponent <UISprite> ().width  = (int)(digitHeight * heightRatio);
                        d.GetComponent <UISprite> ().height = (int)(digitHeight * heightRatio);
                        d.centerer.transform.GetComponent <UIWrapContent> ().itemSize = digitHeight;
                        foreach (Transform c in d.centerer.transform)
                        {
                            c.GetComponent <UISprite> ().height              = digitHeight;
                            c.GetComponent <UISprite> ().width               = digitHeight;
                            c.Find("Label").GetComponent <UILabel> ().width  = (int)(digitHeight * heightRatio);
                            c.Find("Label").GetComponent <UILabel> ().height = (int)(digitHeight * heightRatio);
                            c.Find("Label").localPosition = new Vector3(0, -borderPadding * digitHeight * heightRatio, 0);
                            c.Find("Label").GetComponent <UILabel> ().fontSize = fontSize;
                            if (font != null)
                            {
                                c.Find("Label").GetComponent <UILabel> ().trueTypeFont = font;
                            }
                        }
                    }
                }
            }

            if (useGrid)
            {
                grid.repositionNow = true;
                grid.Reposition();
            }
        }

        List <GameObject> digitsList = new List <GameObject> ();

        foreach (Transform child in grid.transform.Cast <Transform>().OrderBy(t => t.name))
        {
            if (child.gameObject.GetComponent <OdometerDigit> () != null && !child.gameObject.GetComponent <OdometerDigit>().notADigit)
            {
                digitsList.Add(child.gameObject);
            }
        }
        digits = digitsList.ToArray();
        if (digits.Length != numDigits)
        {
            Debug.LogError("ERROR!! max value number of digits must equal number of odometer digits!!! " + digits.Length + "  " + numDigits);
        }
        if (border != null && useBorder)
        {
            UISprite borderSprite = border.GetComponent <UISprite> ();
            borderSprite.enabled           = true;
            borderSprite.width             = (int)(grid.cellWidth * grid.transform.childCount + grid.cellWidth * borderPadding);
            borderSprite.height            = (int)(grid.cellWidth + grid.cellWidth * borderPadding);
            border.transform.localPosition = new Vector3(borderSprite.width / 2 - grid.cellWidth / 2 - grid.cellWidth * borderPadding / 2, 0, 0);
        }

        UpdateOdometerSpringiness(springiness);
        UpdateColors();
    }