0 votes

im learning godot....
im setting up a custom resource to assist in creating items.

all exports work, i need to take the color and apply it to the texture that is input in the inspector. i mainly wanna try and use a small ammount of textures while changing the colors and names.

current item class

extends Resource
classname GenericItem, "res://resources/raw/textures/classicons/items.png"

export(String)var ItemName:String="Generic_Item" #Change in inspector
export(Texture)var ItemTexture:Texture #Added in inspector
export(Color)var ItemColor:Color #Used to change the color of the textures if i can get this to work.

Trying to apply color to given texture for this custom resource without needing to code every color

ItemTexture.Color = ItemColor #does not work
$Sprite.Texture = ItemTexture #does not work

Should i use a setget? i dont want to use them because they are being taken out in the 4.0 update of godot

hopefulle i dont confuse everyone

Godot version 3.3.2
in Engine by (58 points)

If you're using it in the editor, you need to add the keyword tool at the top of your script so it runs in the editor (otherwise it only runs when you launch the project):

tool
extends Resource
classname GenericItem, "res://resources/raw/textures/classicons/items.png"
...

You also need to use setget so the editor reacts immediately when you change the resource. The syntax was only changed for 4.0; they didn't disappear, so you can later port the script to 4.0.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.