logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Tips: How do I... (Read 1245 times)
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3180
Joined: Aug 7th, 2011
Gender: Male
Tips: How do I...
Aug 25th, 2015 at 6:40am
Print Post  
This is a topic about random things that you can do in C++ that are not obvious.



How do I... Iterate over all objects that are relevant to me?

Code
Select All
for( TObjectIterator<UObject> O; O; ++O )
{
}//Iterate over all UObjects.
 



How do I... Convert a "FString" into const TCHAR*? (useful for logging)

Code
Select All
FString F= FString::Printf(TEXT("%s"),TEXT("nedm"));
GLog->LogF(TEXT("%s"),*F);

//the "*" operator on FString converts your FString into a const TCHAR.
 




How do I... Convert a  const TCHAR* to FString?

Code
Select All
const TCHAR *Str = TEXT("nedm");
FString F= FString::Printf(TEXT("%s"),Str);
 



How do I... Load an arbitrary class?
Code
Select All
(UTexture *)StaticLoadObject(UTexture::StaticClass(), NULL,TEXT("Engine.S_Actor"), NULL,LOAD_NoWarn | LOAD_Quiet,NULL);//Load Engine.S_Actor texture.
 




...More to come.
  
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Tips: How do I...
Reply #1 - Aug 25th, 2015 at 9:10am
Print Post  
[]KAOS[]Casey wrote on Aug 25th, 2015 at 6:40am:
How do I... Convert a  const TCHAR* to FString?

Code
Select All
const TCHAR *Str = TEXT("nedm");
FString F= FString::Printf(TEXT("%s"),Str);
 


Why not just use FString constructor here?

Code
Select All
FString F = Str;
FString F2(Str);
auto &&F3 = FString(Str); 


Pre-227 version does not have such a ctor?
  
Back to top
 
IP Logged
 
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3180
Joined: Aug 7th, 2011
Gender: Male
Re: Tips: How do I...
Reply #2 - Aug 25th, 2015 at 4:19pm
Print Post  
That works too, but printf is generally more useful (albeit slower)
  
Back to top
 
IP Logged
 
han
Global Moderator
Unreal Rendering Guru
Developer Team
*****
Offline


Oldunreal member

Posts: 564
Location: Germany
Joined: Dec 10th, 2014
Gender: Male
Re: Tips: How do I...
Reply #3 - Oct 22nd, 2015 at 7:52pm
Print Post  
You can also use the LoadObject<T>() template instead of using StaticLoadObject() directly. This equivalent for for the above example would be:
Code
Select All
LoadObject<UTexture>( NULL, TEXT("Engine.S_Actor"), NULL, LOAD_NoWarn | LOAD_Quiet, NULL );
 

  

HX on Mod DB. Revision on Steam.
Back to top
 
IP Logged
 
atrey
New Member
*
Offline


Oldunreal member

Posts: 4
Joined: Nov 7th, 2018
Re: Tips: How do I...
Reply #4 - Nov 7th, 2018 at 1:57pm
Print Post  
Assuming this is a good post to post a couple of "How do I" questions.

1) Is there some "tick()" equivilent function that loops constantly in-game when coding natively?


2) Similar to question 1, but is there a native looping function that is called in-editor to update that environment? Or is that something that happens in the Render.Render class?


Thanks.
  
Back to top
 
IP Logged
 
han
Global Moderator
Unreal Rendering Guru
Developer Team
*****
Offline


Oldunreal member

Posts: 564
Location: Germany
Joined: Dec 10th, 2014
Gender: Male
Re: Tips: How do I...
Reply #5 - Nov 7th, 2018 at 4:24pm
Print Post  
UEngine::Tick() in it's subclasses used in game/editor.
  

HX on Mod DB. Revision on Steam.
Back to top
 
IP Logged
 
atrey
New Member
*
Offline


Oldunreal member

Posts: 4
Joined: Nov 7th, 2018
Re: Tips: How do I...
Reply #6 - Nov 7th, 2018 at 6:12pm
Print Post  
han wrote on Nov 7th, 2018 at 4:24pm:
UEngine::Tick() in it's subclasses used in game/editor.


Is there a pointer somewhere in AActor, or if not, how would I go about makng one?

Also, is UEngine::Tick() called quicker than UScript's tick?
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo