• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Pixelated_Nate
      Hello all!
      I'm currently designing a 2D, Puzzle/Action RPG, in a similar vein to Legend of Zelda: Link to The Past, in Unity and require a Programmer partner in which to work with me.
      The project, yet to be titled, will feature:
      A semi-open world, represented through pixel art, in which the player traverses to enter dungeons and advance the story. A handful of side-quests that require memorizing details and using puzzle-mechanics. A fast-paced, melee combat system that will include dodging, blocking and utilizing four different attack types that can be switched on the fly. A simple inventory of "Key Items" to be used in order to advance the story. Day & Night system and Weather Effects, with weather effecting combat.  A very simple Dialogue System to convey information via colored text. Saving/Loading via exporting and importing a physical save file. Majority of the project is already planned out, with plans to release commercially and splitting the profits equally among the two of us. 
      I would request that the applicant is able to work semi-independently, following an outline, and that they have experience in both C# programming  *and* putting those scripts to use inside Unity, whilst I will be creating the Art, Music/SFX and doing Level Design (Though if you are also comfortable in assisting me with these, I wouldn't be opposed.).
      Work will be shared in either Github or Unity Collab (Applicants preference), with communication done via Discord. 
      For more information and to apply, please contact me at nathan.jenkins1012@gmail.com
      Thanks for reading! 
    • By Just4lol
      I'm looking for my dream teammate(s) to help me work on my Unity game. I still dont know where Im going with that project but I want to make a good final product that I would be able to sell or publish it for free on Steam.  Here a video of the prototype (The only thing I dint made is the skybox) https://www.youtube.com/watch?v=y2Otmt9jRkc
      My discord : Just4lol#46982
      I want somone at least as competent as me : 
      - I want somone with at least one year of experience in Unity (already worked with scriptable object and know oop).
      - Already worked with shaders or can do editors tools is a plus.
      - Can do 3d models in Blender or can do 2d art for the ui or particles effects.
      - Can make soundtracks or sound effects a bonus.
      Im a french Canadian so mind my english I will do my best to edit any errors I see. 
    • By Damnwing0405
      I am looking for talents to form a team of making a strategy base action game. Talents I am currently looking for are : -
      (I) Unity programmer (mobile)
      (II) Game designer
      (III) 3d Artist
      (IV) SFX Artist
      The attachment is some game concept for the game. All the concept will be turn into 3d or card form. The game will be strategy game where the players can form their own team and control the units in the battle field real time to fight against each others.  If you are interested to know more details please pm me or send an email to damnwing0405@gmail.com

    • By bsudheer
      Leap Leap Leap! is a fast-paced, endless running game where you leap from rooftop to rooftop in a computer simulated world.

      This is a free run game and get excited by this fabulous computer simulated world of skyscrapers and surreal colors in parallax effect. On your way, collect cubes and revival points as many as you can to make a long run.

      Features of Leap Leap Leap:
      -Option of two themes: Black or White.
      -Simple one touch gameplay.
      -Attractive art.
      -Effective use of parallax.
      To Download the game:
      Playstore: https://play.google.com/store/apps/details?id=com.avakaigames.leap
      Appstore: https://itunes.apple.com/us/app/leap-leap-leap/id683764406?mt=8

    • By BillyGD

      Play Flick Football 3D @ https://gamejolt.com/games/flickfootball3d/326078
      Check out our Facebook page @ https://www.facebook.com/FlickFootball3D/
      Flick Football 3D is a turn based football game inspired by the table top classic 'Subbuteo'.
      The game is currently in very early Alpha development. There is still a lot to be done before the first proper release but I have decided to release this playable version to get as much feedback as possible.
      The only game mode currently available in this release is the 'Practice Mode' which gives you control of both teams. Either play against yourself to get used to how the game works or play against friends and family on the same computer!
      Planned Future Features Include:
      -Take control of your own custom team in the single player campaign.
      -Play in online leagues and tournaments against other players in the multiplayer mode.
      -Fully customisable stadiums to make you stand out from the rest of the players.
      -Improve your players stats and skills by playing matches and setting up training sessions.
      Flick Football 3D is available for Windows, Mac and Browser.
      Thank you for viewing my game, all feedback is greatly appreciated. I can be contacted at; BillyGDev@outlook.com
      'Flick Football 3D' is also the development name for the game and I haven't yet decided what the full release will be called, so if you have any ideas please drop me a message!
  • Advertisement
  • Advertisement
Sign in to follow this  

Unity Need help getting classloader to work across DLL boundary

This topic is 4118 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi again, folks, Sorry for the long post, but I'm in need of a bit of help, so I'd really appreciate it if you'd read it. I need a classloader for my project, since it fits the plugin architecture perfectly and will (hopefully) simplify our current method of loading plugins. I'm basing my code pretty much exclusively on the s11n classloader, specifically the version presented in this paper: http://s11n.net/papers/classloading_cpp.html I've taken that code, rearranged it a little, refactored slightly, but it is still functionally equivalent - the one thing I have changed is the static object factory map, from a reference to a pointer, since it wouldn't compile otherwise. Now, I hate people that post all their code up and expect others to read through it all, but I'm really in desperate need here, and I promise it'll only happen this once! My exact code is shown below: ObjectFactory.h

template <typename BaseT, typename SubT = BaseT> // SubT must be-a BaseT.
struct ObjectFactory {
	typedef BaseT resultType;
	typedef SubT actualType;

	static resultType* newInstance() { return new actualType; }
	static resultType* noInstance() { return 0; }



#include <map>

template<typename BaseType, typename KeyType = std::string>
class Instantiator {
	typedef BaseType valueType;
	typedef KeyType keyType;
	typedef valueType *( *factoryType )();
	typedef std::map<keyType, factoryType> objectFactoryMap;

	static valueType* instantiate(const keyType & key) {
		typename objectFactoryMap::const_iterator it = getFactoryMap()->find( key );

		if (it != getFactoryMap()->end())
			return (it->second)();

		return 0;

	static void registerFactory( const keyType & key, factoryType fp = 0 ) {
		if( ! fp ) fp = ObjectFactory<valueType>::noInstance;
		getFactoryMap()->insert( objectFactoryMap::value_type( key, fp ) );

	template <typename SubOfBaseType>
	static void registerSubtype( const keyType & key, factoryType fp = 0 ) {
		if( ! fp ) fp = ObjectFactory<valueType,SubOfBaseType>::newInstance;
		registerFactory( key, fp );

	static objectFactoryMap * getFactoryMap() {
		static objectFactoryMap* meyers = new objectFactoryMap;
		return meyers;

	static bool isRegistered( const keyType & key ) {
		return getFactoryMap()->end() != getFactoryMap()->find( key );


#ifndef ST_TYPE
#error "You must define ST_TYPE before including this file."

#ifndef ST_TYPE_NAME
#error "You must define ST_TYPE_NAME before including this file."

#ifndef ST_BASE_TYPE

#include "Instantiator.h"
#include "ObjectFactory.h"

// Anonymous namespace for linking reasons
namespace {
		// A unique (per Context/per compilation unit) space to assign
		// a bogus value for classloader registration purposes.
		// Included once per compilation unit
		template <typename Context>
		struct stereoshift_reg_context {
			static bool placeholder;

		template<typename Context> bool stereoshift_reg_context<Context>::placeholder = false;
	#endif // ST_REG_CONTEXT

	// Register a factory with the classloader during static initialization
	// Use static dummy variable assigned using comma operator (very cheeky trick)
	bool stereoshift_reg_context< ST_TYPE >::placeholder = (
		// register a no-op factory if registering an abstract class:
			ObjectFactory< ST_TYPE >::noInstance ),
		// register the default factory if not abstract:

// Undef everything so header can be included again
#undef ST_TYPE

... And to show you how this would all be used, here is an example pair of classes: ExampleClass.h

#include <iostream>

class ExampleClass {
	ExampleClass() { std::cout << "base constructing" << std::endl; }
	virtual ~ExampleClass() { std::cout << "base destructing" << std::endl; }

	virtual void run() = 0;

#define ST_TYPE ExampleClass		// the type we want to register
#define ST_TYPE_NAME "ExampleClass"	// the name of the type (need not be the same as the type)
#include "Register.h"				// include the supermacro



#include <iostream>
#include "ExampleClass.h"

class ExampleSubclass : public ExampleClass {
	ExampleSubclass() { std::cout << "subclass constructing" << std::endl; }
	virtual ~ExampleSubclass() { std::cout << "subclass destructing" << std::endl; }

	virtual void run() { std::cout << "subclass running" << std::endl; }

#define ST_TYPE ExampleSubclass			// the type we want to register
#define ST_BASE_TYPE ExampleClass		// the base type of the type we want to register
#define ST_TYPE_NAME "ExampleSubclass"	// the name of the type (need not be the same as the type)
#include "Register.h"					// include the supermacro


Now, this all works fine when in my lovely little test project, when things aren't in DLLs. Everything gets registered statically, and available for instantiation through Instantiator<Base>::instantiate("Name");. But when I put into my actual project, and try to register things in DLLs, things go a bit awry. When I run the debugger on the app, I see that as soon as the DLL is loaded (through whatever means), the register functions are called, which is great, but later on the information is not stored in the static object factory map so all instantiations fail. Now, I'm quite certain this is due to the function:
static objectFactoryMap * getFactoryMap() {
	static objectFactoryMap* meyers = new objectFactoryMap;
	return meyers;
Could it be that I changed the objectFactoryMap to a pointer rather than a reference? I know there are issues with using 'static' things across DLL boundaries, but I'm hoping somebody could point out what my particular problem is! So please, if you can, tell me what's wrong with my code, I'm getting desperate now! Thanks in advance, and than you for being such an awesome community!

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
i think you don't want to recustruct your static map on every call to getFactoryMap(). Check if the pointer already is valid first.

static map_type * the_map = 0;
static map_type *get_map()
{ if(!the_map) the_map = new map_type; return the_map; }

Share this post

Link to post
Share on other sites
Thanks, that helped (well spotted), but the problem is still there. It seems it's more fundamental, as I've noticed in my other thread. I need to separate out the implementation and definition of some of the methods to avoid the code being compiled into both app and DLL, but the restraint of having to keep these in the same file due to the templated classes prevents me from doing this. Looks like I'm going to have to use an inferior solution!

Unless anyone can suggest a way round this, of course....

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement