Esempio n. 1
0
        protected void Awake()
        {
            item   = this.GetComponent <Item>();
            module = item.data.GetModule <Shared.AttachmentModule>();

            //item.OnHeldActionEvent += this.OnHeldAction;

            parentFirearm = this.GetComponent <Weapons.BaseFirearmGenerator>();

            if (!String.IsNullOrEmpty(module.ammoCounterRef))
            {
                ammoCounterMesh   = item.GetCustomReference(module.ammoCounterRef).GetComponent <MeshRenderer>();
                digitsGridTexture = (Texture2D)item.GetCustomReference(module.ammoCounterRef).GetComponent <MeshRenderer>().material.mainTexture;
            }

            //if (digitsGridTexture == null) Debug.LogError("[Fisher-ModularFirearms] COULD NOT GET GRID TEXTURE");
            //if (ammoCounterMesh == null) Debug.LogError("[Fisher-ModularFirearms] COULD NOT GET MESH RENDERER");

            if ((digitsGridTexture != null) && (ammoCounterMesh != null))
            {
                ammoCounter = new TextureProcessor();
                ammoCounter.SetGridTexture(digitsGridTexture);
                ammoCounter.SetTargetRenderer(ammoCounterMesh);
            }

            if (ammoCounter != null)
            {
                ammoCounter.DisplayUpdate(newAmmoCount);
            }
        }