x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Singleton to store GameInstance reference

I want to access to my GameInstance from any place of my code and I created the next singleton class

 class FLYING_API FGlobalAccessor
 {
 public:
     static FGlobalAccessor& Get();
 
     void SetGameInstance(UArenaGameInstance* GameInstance);
     TWeakObjectPtr<UArenaGameInstance> GetGameInstance();
 
 private:
     TWeakObjectPtr<UArenaGameInstance> GameInstance;
 
     static TSharedPtr<FGlobalAccessor> GlobalAccessor;
 }

I want use next construction to access from any place of my code: FGlobalAccessor::Get().GetGameInstance(); But wait... This is static variable! If I ran editor with multiple windows, what I got if I try access to this? I got last setted GameInstance from all windows?

Okay... I thought all windows runs in different threads and I can store accessing to GameInstance by current thread ID, but all windows runs in MainThrd O_O

How to solve this problem? Are there ways?

Special appeal to Rama! You wrote the page where used access to GEngine, Is right way to use it in multiple windows?

Thanks!

Product Version: UE 4.11
Tags:
more ▼

asked Apr 14 '16 at 12:59 PM in C++ Programming

avatar image

broly
519 39 56 83

avatar image rigmania Oct 16 '18 at 10:01 AM

I want to know it, too.

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question