Hello Tony,
I want to highlight any usable object by default, so that my player knows which objects to interact with. I created a component which, depending on enum, can be set as OnEnable or according to distance. Now, how to automatically bind that highlighting component with each object that has Usable? I know I can iterate over each object, but that's ineffective. I can modify Usable component, but any changes would be lost in case of DS update. Is there a way to extend Usable? A partial class somewhere?
Best!
Highlighting usable objects
Re: Highlighting usable objects
Hi Artur,
You can create a subclass of Usable and add this to your GameObjects instead of Usable. The only method that's not currently overridable is Start. I just made the Start method virtual. This will be in the next release. So if you need to override Start, please feel free to change Usable's Start method to virtual:
and then call the base method in your subclass. For example:
You can create a subclass of Usable and add this to your GameObjects instead of Usable. The only method that's not currently overridable is Start. I just made the Start method virtual. This will be in the next release. So if you need to override Start, please feel free to change Usable's Start method to virtual:
Code: Select all
public virtual void Start() {
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class UsableExtended : Usable {
public enum Mode { OnEnable, ByDistance}
public Mode mode;
public override void Start() {
base.Start();
// Your code here to do extra work in Start.
}
public void OnEnable() {
if (mode == Mode.OnEnable) Highlight(1);
}
public void Update() {
if (mode == Mode.ByDistance) Highlight(distanceFromPlayer);
}
public void Highlight(float intensity) {
...
}
}
Re: Highlighting usable objects
Tony,
thank you very much!
Best!
thank you very much!
Best!