greggman / HappyFunTimes

A System for creating 10-100+ player local games
http://greggman.github.io/HappyFunTimes
BSD 3-Clause "New" or "Revised" License
380 stars 55 forks source link

Problems running Unity3d build of game? #13

Open cukiakimani opened 8 years ago

cukiakimani commented 8 years ago

I built a game with HappyFunTimes using unity and I don't know how to run a build? Works fine in the Unity editor, though.

I get the following when I point my controller to "happyfuntimes.net"

TypeError: Cannot read property 'originalGameId' of undefined at handleHappyFunTimesPingRequest ...

If I go straight to the ip address nothing happens just stays at "Waiting for game ..."

It's a OSX Build, btw.

Thanks. :)

greggman commented 8 years ago

Did you pick Window->HappyFunTimes->Export for HappyFunTimes?

Right now you can only run the games from HappyFunTimes. After you export it will create .zip files. Run happyfuntimes, drag and drop the zip file for your platform into the happyfuntimes window and it should install it. Alternatively you can pick Window->HappyFunTimes->Install into Local Happyfuntimes

I've almost got a version ready that no longer needs the external happyfuntimes program at all. It will just run as a normal unity program and none of the special exporting feature are needed

Hopefully I'll have that ready as the 2.0 version of the plugin in 2 or 3 weeks

-gregg

greggman commented 8 years ago

If you'd like to beta test the new 2.0 version you can get it here

Please BACKUP YOUR WORK. Copy your entire project to a new folder and try this in the new folder

Steps

  1. Close Unity
  2. Delete Assets/Plugins/HFTRunner.cs, Assets/Plugins/HappyFunTimes.dll, and Assets/Plugins/Editor/HappyFunTimesEditor.dll
  3. Download the new plugin zip file
  4. Copy everything in inside the Assets folder in that zip file to your project EXCEPT files you changed. For example if you have a custom Assets/WebPlayerTemplates/HappyFunTimes/controller.html don't copy over that.
  5. Now open the project in Unity. You were probably using the PlayerSpawner or PlayerConnector script on one of your objects. (in the samples that's usually on an object called LevelManager). That script is probably missing now so reconnect it. Click the circle next to "Missing Script" and select PlayerSpawner or PlayerConnector, which ever one you were using before.
  6. Rename Assets/WebPlayerTemplates/HappyFunTimes to Assets/WebPlayerTemplates/HappyFunTimes2. Make sure Unity is the front app. Then rename back to Assets/WebPlayerTemplates/HappyFunTimes (this is because the new happyfuntimes has to copy files but it only copies new or modified files. Since your files already exist it can't tell. This rename makes it appear all the files are new).

Things to note:

cukiakimani commented 8 years ago
  1. I did Window->HappyFunTimes->Export for HappyFunTimes

It exported a normal mac .app file in a bin folder. The bin folder being in the main project folder. It did throw the following errors. Even with those errors when I ran the exported .app file with happy fun times running. The game worked with controllers connecting to it just fine.

It only builds the open scene. Is there a way to build multiple scenes with this option?

System.ComponentModel.Win32Exception: ApplicationName='/Applications/HappyFunTimes.app/MacOS/bin/node', CommandLine='"/Applications/HappyFunTimes.app/MacOS/hft/cli/hft.js" "make-release" "/Users/Cukia/OneDrive/Development/Unity/Projects/happyfuntimes/bin" "--platforms=mac" "--json" "--src=/Users/Cukia/OneDrive/Development/Unity/Projects/happyfuntimes"', CurrentDirectory='/Users/Cukia/OneDrive/Development/Unity/Projects/happyfuntimes' at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0 at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0 at System.Diagnostics.Process.Start () [0x00000] in <filename unknown>:0 at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start () at HappyFunTimesEditor.HFTCmdRunner.Run (System.String cmdPath, System.String[] arguments, System.String workingDirectory) [0x00000] in <filename unknown>:0 at HappyFunTimesEditor.HFTCmdRunner.HFTRun (System.String[] arguments, System.String workingDirectory) [0x00000] in <filename unknown>:0 at HappyFunTimesEditor.HFTExport.Export (HappyFunTimesEditor.Options options) [0x00000] in <filename unknown>:0 at HappyFunTimesEditor.HFTExportWindow.ExportHFT () [0x00000] in <filename unknown>:0 at HappyFunTimesEditor.HFTExportWindow.OnGUI () [0x00000] in <filename unknown>:0 UnityEngine.Debug:LogError(Object) HappyFunTimesEditor.HFTExportWindow:OnGUI() UnityEditor.DockArea:OnGUI()

and

NullReferenceException: (null) UnityEditor.SerializedObject..ctor (UnityEngine.Object obj) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/editor/SerializedPropertyBindings.gen.cs:68) HappyFunTimesEditor.HFTExportWindow.Init () HappyFunTimesEditor.HFTExportWindow.OnGUI () System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

  1. When I Window->HappyFunTimes->Install into Local Happyfuntimes it just spat this out with no install into HFT.

System.ComponentModel.Win32Exception: ApplicationName='/Applications/HappyFunTimes.app/MacOS/bin/node', CommandLine='"/Applications/HappyFunTimes.app/MacOS/hft/cli/hft.js" "get-info" "DOgFIghting"', CurrentDirectory='/Users/Cukia/OneDrive/Development/Unity/Projects/happyfuntimes' at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0 at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0 at System.Diagnostics.Process.Start () [0x00000] in <filename unknown>:0 at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start () at HappyFunTimesEditor.HFTCmdRunner.Run (System.String cmdPath, System.String[] arguments, System.String workingDirectory) [0x00000] in <filename unknown>:0 at HappyFunTimesEditor.HFTCmdRunner.HFTRun (System.String[] arguments, System.String workingDirectory) [0x00000] in <filename unknown>:0 at HappyFunTimesEditor.HFTExportWindow.ExportHFT () [0x00000] in <filename unknown>:0 at HappyFunTimesEditor.HFTExportWindow.OnGUI () [0x00000] in <filename unknown>:0 UnityEngine.Debug:LogError(Object) HappyFunTimesEditor.HFTExportWindow:OnGUI() UnityEditor.DockArea:OnGUI()

As of now what works is fine for now as I playtest the game. I will try the new HFT Unity plugin and let you know. Thanks! Love the plugin!

greggman commented 8 years ago

Try the new plugin. I'll cross my fingers it works

cukiakimani commented 8 years ago

@greggman I tried the new plugin. It works okayish in the Unity Editor throws errors about

Could not load: HappyFunTimesAutoGeneratedDoNotEdit/scripts/bower_components/hft-utils/dist/2d.js

and the like but that's just on start up and then works fine.

I tried the build and that didn't work. It creates the server but connecting a controller throws these errors

GET http://10.0.0.6:18679/games/HFTUnity/scripts/bower_components/hft-utils/dist/audio.js Uncaught Error: Script error for: bower_components/hft-utils/dist/audio http://requirejs.org/docs/errors.html#scripterror

greggman commented 8 years ago

Try this

  1. Rename Assets/WebPlayerTemplates/HappyFunTimes to Assets/WebPlayerTemplates/HappyFunTimes2
  2. Make sure Unity is the top window
  3. Rename Assets/WebPlayerTemplates/HappyFunTimes2 back to Assets/WebPlayerTemplates/HappyFunTimes

Now try building again.

The new plugin needs to copy all the files but that folder but it only notices them when they are added or changed. Since in your case they already existed it didn't get a chance to copy them. Renaming should make it notice all the files

greggman commented 8 years ago

And please tell me if that fixes it 🙏

cukiakimani commented 8 years ago

I did what you said. It stopped throwing the errors. Although the controllers are still not connecting. Here's what happens

  1. "Looking for happyfuntimes"
  2. Displays the controller for a split second (player doesn't spawn in game)
  3. "Switching games..."
  4. "Touch to reset"

If you touch to reset you just go through the same steps.

This is only in the build though. In the Unity Editor the controller connects and no errors.

greggman commented 8 years ago

Thanks for that info. That's really helpful! I will look into it

greggman commented 8 years ago

I uploaded a new version that seems to be work in builds. At least for me. It's still generating a few errors behind the scenes after you stop and start the game if controllers are waiting to reconnect. I'm trying to decide how best to deal with that and trying to decide how compatible to keep it with the previous system

In any case please give it a try using the steps listed above