Welcome to another Smile Game Builder tutorial, showcasing some of the features and tricks I've found and worked on while developing "The Ocean Will Have Us All."
In this tutorial I'm going to show you how to get at the variables in a game exported from Smile Game Builder to Unity.
Step 1. We'll create a new project.
Step 2. Put in a new "advanced event."
Change the graphic to a character so we can see them.
Step 3. Let's set this event up to put a message in a string variable that we'll output in Unity and display another variable with a message from Unity.
Put in a "Change String Variable Box" event. Set it to variable number 254 and rename it to "MessageToUnity". Also rename string variable 255 to "MessageFromUnity".
Set it to "Substitute String" with "Hello Unity!"
Then create a "Display Message" event: "\$[MessageFromUnity]"
Step 4. Playtest the game. Talk to the character, a blank message box appears.
Step 5. Export the game to Unity.
Step 6. Open the exported project in Unity. Open it from the "entry.unity" file.
Step 7. Let's create a script for our unity hackin'. We'll call it "MyUnityHacks"
Create a gameobject and add the script.
Step 8. Open up "MyUnityHacks.cs"
We'll add some static variables (hackin'!) that we'll copy our variables to from within the Smile Game Builder code (more hackin').
Add these lines to the class:
public static string MessageFromUnity;
public static string MessageToUnity;
In void Start() add
MessageFromUnity = "Hello Smile Game Builder!"
in void Update() add
if(MessageToUnity != null)
{
Debug.Log(MessageToUnity);
}
Step 9. Open up "Assets\src\engine\ScriptRunner.cs"
Step 10. Look for "internal bool Update()" and add these lines
MyUnityHacks.MessageToUnity = owner.owner.data.system.StrVariables[254];
owner.owner.data.system.StrVariables[255]= MyUnityHacks.MessageFromUnity;
Now every frame MessageToUnity in MyUnityHacks will be updated with whatever is in string variable 254 [MessageToUnity] in your SGB game.
And every frame string variable 255 [MessageFromUnity] will be updated with whatever you've put in MessageFromUnity in the MyUnityHacks script.
All the integer variables from your game are stored in the array owner.owner.data.system.Variables[]
All the event switches are in owner.owner.data.system.Switches[]
Step 11. Run the project in Unity. Talk to the character. This time the message box should say "Hello Smile Game Builder!"
In the console in Unity you'll see the "Hello Unity!" message (repeated every frame.)
Step 12. Use your imagination! Extend your games in new and exciting ways in Unity! Do amazing things!
The Ocean Will Have Us All
Moloch Media
Moloch Media
in the future
Singleplayer
Game News Posts 2
🎹🖱️Keyboard + Mouse
🎮 Full Controller Support
No user reviews
(0 reviews)
https://store.steampowered.com/app/1375820 
Experience a day in the subatomic life of Moira Leech. Get up, go to work, go home, go back to sleep.
Or.
Go off the the beaten track! Take charge! Stick your finger in an electrical socket!
A neutopian mysterium adventure game from Moloch Media.
- Meet and interact with the characters that live on your street.
- Or just ignore them.
- Go off on tangential subplots.
- Get in trouble.
- Listen to dynamic cassette chip music.
- Look at a high-fidelity fully 3D texture mapped world.
- OS: Ubuntu 16.04+
[ 5951 ]
[ 3154 ]