Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ifdef for macro compatibility #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion example-project/EZPlatformer/source/import.hx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if !macro
import FmodConstants.FmodSFX;
import FmodConstants.FmodSongs;
import haxefmod.FmodManager;
import haxefmod.FmodManager;
#end
10 changes: 8 additions & 2 deletions fmod-scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This script utilizes a very cool feature in FMOD Studio to give your code access

It does this by placing an `FmodConstants.hx` file next to your main `.hx` file which you can then import into your project.

If you are using vscode, its autocomplete can be triggered by typing in "FmodSongs." or "FmodSFX."
If you are using vscode, its autocomplete can be triggered by typing in "FmodSongs." or "FmodSFX."

![Haxe Constants Demo](https://raw.githubusercontent.com/Tanz0rz/haxe-fmod/34baff733a24e4301b6b8457066cae870fb22570/HaxeConstants.gif)

Expand All @@ -23,17 +23,23 @@ To avoid having to import three classes in every file of your game code, you can

`import.hx`:
```haxe
// Only use imports when not in the macro context.
// The FMOD files use build macros and will throw errors if imported within the macro context.
#if !macro

// Fmod helper library
import haxefmod.FmodManager;
// Static class containing all sound effect names
import FmodConstants.FmodSFX;
// Static class containing all song names
import FmodConstants.FmodSongs;

#end
```

## Installing the script:
- Place the ExportHaxeConstants.js file in your FMOD Studio's "scripts" folder. This folder will be found wherever you installed FMOD Studio on your computer.
- In FMOD Studio, click the Scripts dropdown at the top and select "Reload".
- In FMOD Studio, click the Scripts dropdown at the top and select "Reload".
- Click on the Scripts dropdown again and you will see an "Export Haxe Constants" option now available.
- When prompted, select the directory in your Haxe project that contains your `Main.hx` file (this is usually the `/source` directory).

Expand Down