Example #1
0
    ///<summary>
    /// Update object's color according to its Tenant.
    ///</summary>
    public void UpdateColorByTenant()
    {
        if (string.IsNullOrEmpty(domain))
        {
            return;
        }

        OgreeObject tenant = ((GameObject)GameManager.gm.allItems[domain]).GetComponent <OgreeObject>();

        Material mat = transform.GetChild(0).GetComponent <Renderer>().material;

        color = new Color();
        ColorUtility.TryParseHtmlString($"#{tenant.attributes["color"]}", out color);

        CustomRendererOutline cro = GetComponent <CustomRendererOutline>();

        if (cro && !cro.isSelected && !cro.isHovered && !cro.isHighlighted && !cro.isFocused)
        {
            mat.color = new Color(color.r, color.g, color.b, mat.color.a);
        }
    }
Example #2
0
    ///<summary>
    /// Set a Color with an hexadecimal value
    ///</summary>
    ///<param name="_hex">The hexadecimal value, without '#'</param>
    public void SetColor(string _hex)
    {
        Material mat = transform.GetChild(0).GetComponent <Renderer>().material;

        color = new Color();
        bool validColor = ColorUtility.TryParseHtmlString($"#{_hex}", out color);

        if (validColor)
        {
            color.a = mat.color.a;
            CustomRendererOutline cro = GetComponent <CustomRendererOutline>();
            if (cro && !cro.isSelected && !cro.isHovered && !cro.isHighlighted && !cro.isFocused)
            {
                mat.color = color;
            }
            attributes["color"] = _hex;
        }
        else
        {
            UpdateColorByTenant();
            attributes.Remove("color");
            GameManager.gm.AppendLogLine("Unknown color", true, eLogtype.warning);
        }
    }