Beispiel #1
0
    private void GenerateSymbol(int id, Vector3 position)
    {
        // Instantiate the symbol at the origin using the prefab
        Transform newSymbolTF = Instantiate(prefab_symbol, position, Quaternion.LookRotation(Vector3.back)) as Transform;

        // Set the symbol to be a child of this empty object and then set the local position
        newSymbolTF.parent        = transform;
        newSymbolTF.localPosition = position;

        // Set the material according to the symbol ID
        Material newSymbolMat = newSymbolTF.gameObject.GetComponent <Renderer> ().material;

        newSymbolMat.SetColor("_EmissionColor", Color.black);

        // Set the texture for the material to the correct symbol (from Assets/Resources/Totem#/#.png)
        string  fileName = "Totem" + parent_totem.GetTotemNum() + "/" + id;
        Texture texture  = Resources.Load(fileName) as Texture;

        newSymbolMat.mainTexture = texture;
        newSymbolMat.SetTexture("_EmissionMap", texture);

        // Set the symbol's id and update the symbols list
        Symbol newSymbol = newSymbolTF.gameObject.GetComponent <Symbol> ();

        newSymbol.Init(gparent_gridSpace, parent_totem, id, rows, index, tileHeight);
        symbolList [id] = newSymbol;

        symbolCount++;
    }