I made UDataAsset.
And I want to call BeginPlay function on UDataAsset.
I just put BeginPlay function on UDataAsset script just like Actor does.
But it didn't work.
How can I do this?
UCLASS()
class GAME_API UCData : public UDataAsset
{
GENERATED_BODY()
public:
void BeginPlay(class ACharacter* InCharacter);
}
This didn't work for me...
Am I missing something?
Please help me..
For reference, UDataAsset inherits from UObject; UObject doesn't include a function for BeginPlay, so you won't get the behaviour you would expect if the data asset inherited from AActor.
If there is an owner for the data asset, they can provide that call into your version of BeginPlay.
I found the solution. UDataAsset can't have beginPlay so I called BeginPlay on DataAsset from the other component.
Related
MyHUD.h
UCLASS()
class FPS_API AMyHUD : public AHUD
{
GENERATED_BODY()
UPROPERTY(EditDefaultsOnly, Category = Gameplay)
class UUserWidget* DefaultWidget;
...
}
I make Blueprint BP_MyHUD extends MyHUD and Widget Blueprint. The problem is, the DefaultWidget in BP_MyHUD is set None after i restart UE4 program or compile using button in toolbar at Blueprint editor. How can i fix the value of DefaultWidget in BP_MyHUD?
By default variables are set to "Private" and thus can't be modified in derived classes.
Try putting this UPROPERTY after you say public: (you could also use protected:)
UCLASS()
class FPS_API AMyHUD : public AHUD
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, Category = Gameplay)
class UUserWidget* DefaultWidget;
...
}
Also I am unsure of the EditDefaultsOnly specifier when it comes to blueprints. My understanding was without
BlueprintReadWrite
You could not edit the variables in blueprints. But if you've been using this with success with other variables it is likely not the problem.
A bit late to the party, but here's the answer:
It's not possible.
Non-BindWidget pointers with EditDefaultsOnly indeed generate a selector in the Details panel, but this selector is not meant to select a widget inside our component's archetype. It's meant to select a widget outside an instance of our component (it also need to be public and maybe a BlueprintReadWrite too). In this case, the value you put in the selector indeed stay across builds.
Sadly, this error-inducing selector appearing anyway means that two things aren't quite working properly around this behaviour :
At the moment UE clears the selector when you're building, it should really display a warning/error explaining why
You shouldn't really be able to put EditAnywhere/EditDefaultsOnly on a non-BindWidget property, only a EditInstanceOnly... yet there's no warning/error either =(
(credits to #Bohdon Sayre from BenUI's discord community for helping me on this one)
The question about the calling of the custom .net method implemented in the TurnKey_ExternalLateBound.dll.
I remember that it worked for me, but it was long time ago.
I tried this article and I put simple code:
public IElement Execute(IClassifier classifier, IObject theobject, IMethod method, IModifiableVariableList variableList)
{
throw new NotImplementedException();
}
But I got nothing in the Turnkey. The tagged value of the class's method is ok. Viewmodel's action column calls this method.
Could you please advise what should I do else?
Thanks a lot!
I want to use BroadcastReceiver inside SystemSensorManager class (android.hardware). I managed to define an object of type BroadcastReceiver but when I tried to register this receiver using :
registerReceiver(BroadcastReceiver receiver, IntentFilter filter)
This method cannot be found and the source code doesnt compile.
I tried the to do similar thing in the Activity class and it succeeded. whats wrong with the SystemSensorManager class ?
registerReceiver is defined on Context and its descendants. SystemSensorManager receives context in constructor, but does not remember it. You should find a relevant Context for your change.
I know that in AS3 I can create a Main class and link it to the FLA file. I tried doing the same in AS2 but couldn't. (When I try linking the fla to a class, it says the feature only exists in AS3)
Can I link the FLA to a class in some other way? If this is not possible, how would you suggest I perform actions when the file is loaded (and, in this case, define an ExternalInterface)?
Thank you.
here is the approach i would use. you define a static method in your 'document' class and then pass in the reference to your main timeline at runtime:
class MyClass extends MovieClip
{
public static function main(target:MovieClip):Void
{
target.__proto__ = MyClass.prototype;
target.init();
}
private function init():Void
{
// your construction code....
}
}
Then in your FLA, on the first frame, invoke the class's static 'main' and pass it the main timeline movieclip as the argurment. this is kinda like wrapping the timline with your document class.
MyClass.main(this);
Example based on http://www.bit-101.com/blog/?p=857. i just added it here to fix up the broken code tags on his site.
I want to handle different types of docs the same way in my application
Therefore:
I have a generic interface like this.
public interface IDocHandler<T>where T: class
{
T Document { get;set;}
void Load(T doc);
void Load(string PathToDoc);
void Execute();
void Execute(T doc);
}
And for different types of documents I implement this interface.
for example:
public class FinanceDocumentProcessor:IDocumentHandler<ReportDocument>
{}
public class MarketingDocumentProcessor:IDocumentHandler<MediaDocument>
{}
Then I can do of course something like this:
IDocumentHandler<ReportDocument> docProc= new FinanceDocumentProcessor();
It would be interessting to know how I could inject T at runtime to make the line above loosly coupled...
IDocumentHandler<ReportDocument> docProc = container.resolve("FinanceDocumentProcessor());
but I want to decide per Configuration wether I want to have my FinanceDomcumentProcessor or my MarketingDocumentProcessor... therefore I would have to inject T on the left site, too ...
Since I have to use c# 2.0 I can not use the magic word "var" which would help a lot in this case... but how can I design this to be open and flexible...
Sorry for the misunderstanding and thanks for all the comments but I have another example for my challenge (maybe I am using the wrong design for that) ...
But I give it a try: Same situation but different Explanation
Example Image I have:
ReportingService, Crystal, ListAndLabel
Three different Reporting Document types. I have a generic Handler IReportHandler<T> (would be the same as above) this Handler provides all the functionality for handling a report Document.
for Example
ChrystalReportHandler:IReportHandler<CrystalReportDocument>
Now I want to use a Framework like Unity (or some else framework) for dependency injection to decide via configuration whether I want to use Crystal, Reportingservices or List and Label.
When I specify my mapping I can inject my ChrystalReportHandler but how can I inject T on the left side or in better word The Type of ReportDocument.
IReportHandler<T (this needs also to be injected)> = IOContainer.Resolve(MyMappedType here)
my Problem is the left Site of course because it is coupled to the type but I have my mapping ... would it be possible to generate a object based on Mapping and assign the mapped type ? or basically inject T on the left side, too?
Or is this approach not suitable for this situation.
I think that with your current design, you are creating a "dependency" between IDocumentHandler and a specific Document (ReportDocument or MediaDocument) and so if you want to use IDocumentHandler<ReportDocument or MediaDocument> directly in your code you must assume that your container will give you just that. The container shouldn't be responsible for resolving the document type in this case.
Would you consider changing your design like this?
public interface IDocumentHandler
{
IDocument Document { get; set; }
void Load(IDocument doc);
void Load(string PathToDoc);
void Execute();
void Execute(IDocument doc);
}
public class IDocument { }
public class ReportDocument : IDocument { }
public class MediaDocument : IDocument { }
public class FinanceDocumentProcessor : IDocumentHandler { }
public class MarketingDocumentProcessor : IDocumentHandler { }
If I understand you correctly, you have two options.
if you have interface IDocHandler and multiple classes implementing it, you have to register each type explicitly, like this:
container.AddComponent>(typeof(FooHandler));
if you have one class DocHandler you can register with component using open generic type
container.AddComponent(typeof(IDocHandler<>), typeof(DocHandler<>));
then each time you resolve IDocHandler you will get an instance of DocHandler and when you resolve IDocHandler you'll get DocHandler
hope that helps
You need to use a non-generic interface on the left side.
Try:
public interface IDocumentHandler { }
public interface IDocumentHandler<T> : IDocumentHandler { }
This will create two interfaces. Put everything common, non-T-specific into the base interface, and everything else in the generic one.
Since the code that you want to resolve an object into, that you don't know the type of processor for, you couldn't call any of the T-specific code there anyway, so you wouldn't lose anything by using the non-generic interface.
Edit: I notice my answer has been downvoted. It would be nice if people downvoting things would leave a comment why they did so. I don't care about the reputation point, that's just minor noise at this point, but if there is something seriously wrong with the answer, then I'd like to know so that I can either delete the answer (if it's way off target) or correct it.
Now in this case I suspect that either the original questionee has downvoted it, and thus either haven't posted enough information, so that he's actually asking about something other than what he's asked about, or he didn't quite understand my answer, which is understandable since it was a bit short, or that someone who didn't understand it downvoted it, again for the same reason.
Now, to elaborate.
You can't inject anything "on the left side". That's not possible. That code have to compile, be correct, and be 100% "there" at compile-time. You can't say "we'll tell you what T is at runtime" for that part. It just isn't possible.
So the only thing you're left with is to remove the T altogether. Make the code that uses the dependency not depend on T, at all. Or, at the very least, use reflection to discover what T is and do things based on that knowledge.
That's all you can do. You can't make the code on the left side change itself depending on what you return from a method on the right side.
It isn't possible.
Hence my answer.