Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your options for generic programming in UnrealScript are limited, unfortunately. One option may be to put your operator overload in an include file and include it in each class that needs it using the <code>`include</code> macro.</p> <p>If that doesn't work, another option may be to use a macro to invoke a static function in a special class for handling struct to string conversions.</p> <p>First create a Globals.uci file in your code package's root folder. Globals.uci is a special file which is automatically included by the compiler in all UncrealScript files in the package it is associated with. If your package is called MyPackage, Globals.uci would go in Development/Src/MyPackage/Globals.uci. It should be next to the Classes folder for your package.</p> <p>Put your macro in Globals.uci:</p> <pre><code>`define toString(type,name) class'MyStructConversions'.static.`{type}ToString(`{name},"`{name}") </code></pre> <p>Put your conversion function in MyStructConversions.uc:</p> <pre><code>class MyStructConversions; static function string Vector2DToString (const out Vector2D A, string varname) { return varname $ ": (" $ A.X $ ", " $ A.Y $ ")"; } </code></pre> <p>Now when you call <code>`toString(Vector2D, impulse)</code> from anywhere in your package the macro will be replaced at compile time with an invocation to your Vector2DToString function. You can then support more struct types by adding the appropriate definitions to MyStructConversions.uc, and the toString macro will work seamlessly with them.</p> <p>The documentation on the <a href="http://udn.epicgames.com/Three/UnrealScriptPreprocessor.html" rel="nofollow">UnrealScript preprocessor</a> has more information on <code>`include</code> and other macros. Check out Globals.uci in Development/Src/Core for some useful examples as well.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload