I would like to get my attribute to take in sprites but I’m of course having issues with the sprites needing to be const. Is there an easy way to make this happen or should I change the attribute to an interface or abstract class?(Leaning toward interface at this point)
here’s what I have currently:
[System.AttributeUsage(System.AttributeTargets.Method)]
public class UtilityButtonAttribute : System.Attribute{
public Sprite buttonImage, highlightImage, pressedImage, disabledImage;
public UtilityButtonAttribute(Sprite buttonImage){
this.buttonImage = buttonImage;
}
public UtilityButtonAttribute(Sprite buttonImage, Sprite pressedImage){
this.buttonImage = buttonImage;
this.pressedImage = pressedImage;
}
public UtilityButtonAttribute(Sprite buttonImage, Sprite pressedImage, Sprite highlightImage){
this.buttonImage = buttonImage;
this.pressedImage = pressedImage;
this.highlightImage = highlightImage;
}
public UtilityButtonAttribute(Sprite buttonImage, Sprite pressedImage, Sprite highlightImage, Sprite disabledImage){
this.buttonImage = buttonImage;
this.pressedImage = pressedImage;
this.highlightImage = highlightImage;
this.disabledImage = disabledImage;
}
}
public class utilityButtonControl : MonoBehaviour {
public const Sprite spr = Object.FindObjectOfType<utilityButtonControl>().spr2;
public Sprite spr2;
[UtilityButtonAttribute(spr)]
public void o(){
}
}
sorry if the code has errors or is incomplete I just wanted to have enough to ask my question:p