General And Unity Game Related programming tutorials and code repository

Expandmenu Shrunk


  • Unity Plugin Project Code.

    In my haste to get code up for you guys, I found the folder that I was sure contained the completed projects for my videos.

    I pushed it up to github, thinking that would give everyone what they needed… Boy was I wrong.

    the OSX code seems to have been omitted because it had a .git repo of its own. And I apparently dont have the C# version anymore at all.

    I have posted up the latest code for the projects that I was able to locate, Unfortunately I have not had the chance to test them.

    I did however notice that the project did not include the OSX Callback code that emulates “SendMessage” which means I will need to relocate, or redevelop the code for the repo.

    I apologize for the issues, The machine I originally developed it on I have been relieved of.

    Here is the link to the existing code. https://github.com/superlazycoder/UnityPluginsCollection



  • Unity Plugins on Mac OSX

    I have been building plugins for a lot of different needs, but my biggest headache with mac OSX has been that whenever I use a plugin, Whether through dlopen or DllImport the application hangs when closed. the only way I could close the app was to “Force Quit” and wait.

    Well no longer. I’m really tired of mac getting the better of me. So I built a “Destroy” method on my plugins.

    No need to destroy each plugin, this destroy method is for when I am about to close the application.

    exit(0);

    I was really trying to avoid this type of fix, but there’s not much else I can think of.

    Here is a sample of my plugin.

    Exports Header file.

    Exports Implementation file.

    As you can see I called exit right int the C++ implementation file.

    as for HookWindow, In case you were interested.

    HookWindow Header file

    HookWindow Implementation File

    Finally is the Unity Scripts.. First we will do the Dll Bridge implementation.

    And finally the Static Script that will get the application exiting message.

    you will see the Destroy call on Line 17.

    but you will also see on line 10 that I told it no to destroy. This will keep this script floating around on the game object it is attached to until you close the application.

    Im sure there is a better way than this, but this fixed the problem for me. I hope this can help others.



  • DllImport vs LoadLibrary/dlopen

    DllImport is supposed to have a direct correlation with LoadLibrary, and subsequently dlopen on mac/linux. However with unity, there are a few api calls that Unity forwards to you when you start your app and when you ask for a render call.

    Adding the following exports


    extern "C" void EXPORT_API UnitySetGraphicsDevice (void* device, int deviceType, int eventType);

    extern "C" void EXPORT_API UnityRenderEvent (int eventID);

    will enable unity to send your plugin Graphics and Render calls. However this only seems to happen if you use DllImport, not when you use dlopen or LoadLibrary.

    Currently this is just something to note. I am going to be working on a way to get the plugin back into the render pipeline, If I can.

    Also, I will be testing the render pipeline on iPhone and Android testing out some in game Movie Textures.



  • App Release

    Again with the delays.

    The app I am working on is supposed to be releasing but the iphone is having a whole slew of issues. I have not even made it to the android version yet. But I digress. Working Diligently to get this product out, but Im still thinking of the cool things I can do with unity.

    Hoping to get some Editor tutorials up and running. Unity Editor is awesome.



  • libMobileVLC

    I spent quite a while getting libMobileVLCKit working for the iPhone on OSX.

    Things I am taking for granted:

    You are developing with command line tools installed

    You are on a macintosh 10.8 or above

    You have Xcode 5 installed

     

    Aside from these requirements, I also hunted down some of the older sdk’s from developer.apple.com
    You will need a valid developer account to get to these links.

    The list is located at: https://developer.apple.com/downloads/index.action?name=Xcode#

    Xcode 5.0.1 contains ios sdk 7.0:  http://adcdownload.apple.com/Developer_Tools/xcode_5.0.1/xcode_5.0.1.dmg

    Xcode 4.6.2 contains ios sdk 6.0: http://adcdownload.apple.com/Developer_Tools/xcode_4.6.2/xcode4620419895a.dmg

     

    These sdk’s are located inside the app contents in the following directory

    /Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs

    Place all of the sdk’s into the Xcode.app that you do your development with. Typically located at “/Applications/Xcode.app”

    Right click xcode and select “Show Package Contents”
    Show Package Contents

     

    Navigate to the SDKs Folder and put the missing sdks into your installed version of xcode.
    Navigate to the SDKs folder

     

    Now, before we get to compiling VLCKit you need to get the gas-preprocessor.pl

    I added this file to my /usr/bin folder and modified its mode to allow execution.


    sudo cp gas-preprocessor.pl /usr/bin
    sudo chmod +x gas-preprocessor.pl

    at this point running gas-preprocessor.pl from the command line yielded this response


    Unrecognized input filetype at /usr/bin/gas-preprocessor.pl line 33.

    which apparently is not a problem. It probably accepts some arguments that Im just not supplying.
    However this command is needed to compile ffmpeg which libvlc works on.

    the next thing I did was clone the latest vlckit to my computer and compile with the provided build script.

    Don’t open any of the xcodeproj files provided with the repo files. Each time I did this the compile screwed up for some reason or another.


    git clone git://git.videolan.org/vlc-bindings/VLCKit.git
    cd VLCKit/
    ./buildMobileVLCKit.sh

    This build process took what must have been an hour or better. And this mac is not too shabby.
    When the process completed I was able to use the compiled versions of libMobilevlc

    a simple find command yields all the compiled libraries


    $ find ./ -name "*vlc*.a"
    .//MobileVLCKit/ImportedSources/vlc/build-ios-OS/arm64/lib/.libs/libvlc.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-OS/arm64/modules/.libs/libvlc_srtp.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-OS/arm64/modules/control/.libs/libvlc_motion.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-OS/arm64/src/.libs/libvlccore.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-OS/armv7/lib/.libs/libvlc.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-OS/armv7/modules/.libs/libvlc_srtp.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-OS/armv7/modules/control/.libs/libvlc_motion.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-OS/armv7/src/.libs/libvlccore.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-OS/armv7s/lib/.libs/libvlc.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-OS/armv7s/modules/.libs/libvlc_srtp.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-OS/armv7s/modules/control/.libs/libvlc_motion.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-OS/armv7s/src/.libs/libvlccore.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-Simulator/i386/lib/.libs/libvlc.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-Simulator/i386/modules/.libs/libvlc_srtp.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-Simulator/i386/modules/control/.libs/libvlc_motion.a
    .//MobileVLCKit/ImportedSources/vlc/build-ios-Simulator/i386/src/.libs/libvlccore.a
    .//MobileVLCKit/ImportedSources/vlc/install-ios-OS/arm64/lib/libvlc.a
    .//MobileVLCKit/ImportedSources/vlc/install-ios-OS/arm64/lib/libvlccore.a
    .//MobileVLCKit/ImportedSources/vlc/install-ios-OS/armv7/lib/libvlc.a
    .//MobileVLCKit/ImportedSources/vlc/install-ios-OS/armv7/lib/libvlccore.a
    .//MobileVLCKit/ImportedSources/vlc/install-ios-OS/armv7s/lib/libvlc.a
    .//MobileVLCKit/ImportedSources/vlc/install-ios-OS/armv7s/lib/libvlccore.a
    .//MobileVLCKit/ImportedSources/vlc/install-ios-Simulator/i386/lib/libvlc.a
    .//MobileVLCKit/ImportedSources/vlc/install-ios-Simulator/i386/lib/libvlccore.a

    the ones I was looking for are libvlc.a and libvlccore.a for ios armv7, however at this point the projects that came with VLCKit finally work.