Example #1
0
 public static void ShowBlock(NBTObject generator, short data)
 {
     instance.handMeshRenderer.enabled   = false;
     instance.blockMeshFilter.sharedMesh = generator.GetItemMesh(NBTHelper.GetChunk(GetCurrentBlock()), (byte)data);
     instance.blockMeshRenderer.GetComponent <MeshRenderer>().sharedMaterial = generator.GetItemMaterial((byte)data);
     instance.blockMeshFilter.transform.gameObject.SetActive(true);
 }
Example #2
0
 public static void ShowBlock(NBTObject generator, short data)
 {
     instance.handMeshRenderer.enabled = false;
     try
     {
         instance.blockMeshFilter.sharedMesh = generator.GetItemMesh(NBTHelper.GetChunk(GetCurrentBlock()), Vector3Int.RoundToInt(instance.position), (byte)data);
     }
     catch (System.Exception e)
     {
         Debug.LogError("showblock error, generator=" + generator + ",message=\n" + e.Message);
     }
     instance.blockMeshRenderer.GetComponent <MeshRenderer>().sharedMaterial = generator.GetItemMaterial((byte)data);
     instance.blockMeshFilter.transform.gameObject.SetActive(true);
 }
Example #3
0
    // Start is called before the first frame update
    void Start()
    {
        shadowTrans = transform.Find("shadow");
        shadow      = shadowTrans.GetComponent <Renderer>().material;

        meshTrans = transform.Find("mesh_parent/mesh");
        MeshFilter meshFilter = meshTrans.GetComponent <MeshFilter>();

        Vector3Int pos = Vector3Int.RoundToInt(transform.position);

        meshFilter.sharedMesh           = generator.GetItemMesh(NBTHelper.GetChunk(PlayerController.GetCurrentBlock()), pos, blockData);
        meshFilter.transform.localScale = generator.itemSize;

        meshTrans.GetComponent <MeshRenderer>().sharedMaterial = generator.GetItemMaterial(blockData);

        RefreshMesh();
    }
Example #4
0
    // Start is called before the first frame update
    void Start()
    {
        shadowTrans = transform.Find("shadow");
        shadow      = shadowTrans.GetComponent <Renderer>().material;

        meshTrans = transform.Find("mesh_parent/mesh");
        MeshFilter meshFilter = meshTrans.GetComponent <MeshFilter>();

        meshFilter.sharedMesh = generator.GetItemMesh(NBTHelper.GetChunk(PlayerController.GetCurrentBlock()), blockData);
        if (generator is NBTBlock && !(generator is NBTPlant))
        {
            meshFilter.transform.localScale = Vector3.one / 2;
        }

        meshTrans.GetComponent <MeshRenderer>().sharedMaterial = generator.GetItemMaterial(blockData);

        RefreshMesh();
    }