Ejemplo n.º 1
0
    public static GameObject CreateDecal(SDecalInfo Info)
    {
        Material   sharedMat = GameObject.Instantiate(CGame.WorldResources.DecalMat);
        GameObject Gob       = null;

        if (Info.mType == CDecal.EDecalType.TEXT)
        {
            Gob = new GameObject("decal");

            TextMesh textMesh = Gob.AddComponent <TextMesh>();
            Gob.GetComponent <MeshRenderer>().material = sharedMat;
            sharedMat.SetTexture("_MainTex", CGame.WorldResources.DecalFontA.material.GetTexture("_MainTex"));
            sharedMat.SetFloat("_Add", 1.0f);
            textMesh.font          = CGame.WorldResources.DecalFontA;
            textMesh.text          = Info.mText;
            textMesh.characterSize = 0.2f;
            textMesh.fontSize      = 54;
            textMesh.color         = new Color(1.0f, 1.0f, 1.0f, 1.0f);
            textMesh.anchor        = TextAnchor.MiddleCenter;
        }
        else if (Info.mType == CDecal.EDecalType.IMAGE)
        {
            Gob      = GameObject.CreatePrimitive(PrimitiveType.Quad);
            Gob.name = "decal";
            Gob.GetComponent <MeshRenderer>().material = sharedMat;
            sharedMat.SetTexture("_MainTex", CGame.PrimaryResources.GetDecalImage(Info.mVisualId));
        }

        Gob.transform.localPosition = Info.mPosition;
        Gob.transform.rotation      = Info.mRotation;
        Gob.transform.localScale    = new Vector3(Info.mSize.x, Info.mSize.y, 1.0f);
        sharedMat.SetColor("_Color", Info.mColor);

        Gob.AddComponent <Item>().Init(sharedMat);

        return(Gob);
    }