private static void CopyTMPColorToMOC()
    {
        Transform[]       ts        = FindObjectsOfType <Transform>();
        List <GameObject> selection = new List <GameObject>();

        foreach (Transform t in ts)
        {
            TMPro.TextMeshPro          cs  = t.gameObject.GetComponent <TMPro.TextMeshPro>();
            MaterialOverrideController moc = t.gameObject.GetComponent <MaterialOverrideController>();
            if (cs == null || moc == null)
            {
                continue;
            }

            if (cs.color.a >= 1)
            {
                continue;
            }

            var match = moc.Properties.FirstOrDefault <MaterialOverrideProperty>(
                x => x.name.Equals("_FaceColor")
                );

            if (match != null)
            {
                match.type       = MaterialOverrideProperty.PropType.Color;
                match.colorValue = cs.color;
            }
            else
            {
                moc.Properties.Add(new MaterialOverrideProperty()
                {
                    name       = "_FaceColor",
                    type       = MaterialOverrideProperty.PropType.Color,
                    colorValue = cs.color
                });
            }

            selection.Add(t.gameObject);
        }
        Selection.objects = selection.ToArray();
    }
예제 #2
0
    private static void Setup(MenuCommand menuCommand)
    {
        var tmp = menuCommand.context as TextMeshPro;

        MaterialOverrideController moc = tmp.gameObject.GetComponent <MaterialOverrideController> ();

        if (moc == null)
        {
            moc = tmp.gameObject.AddComponent <MaterialOverrideController> ();
        }

        moc.RefreshMode = MaterialOverrideRefreshMode.EveryFrame;

        tmp.gameObject.GetComponent <RectTransform>().sizeDelta = new Vector2(500, 500);

        tmp.alignment = TextAlignmentOptions.Center;

        tmp.font                   = Resources.Load("Localization/Fonts/en/BeachBarScriptBlack SDF") as TMP_FontAsset;
        tmp.isOrthographic         = true;
        tmp.parseCtrlCharacters    = true;
        tmp.richText               = true;
        tmp.useMaxVisibleDescender = true;
    }