Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | reapersremorse |
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
class_name GenericItem, “res://resources/raw/textures/class_icons/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
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.
Ev1lbl0w | 2021-08-26 13:20