public void SubscribeToEvent(StringHash e, Object sender, Action <StringHash, VariantMap> eventHandler) { IntPtr handle = GCHandle.ToIntPtr(GCHandle.Alloc(eventHandler)); IntPtr callback = Marshal.GetFunctionPointerForDelegate(EventHandlerCallbackInstance); Urho3D_Object_SubscribeToEvent(swigCPtr, getCPtr(sender), e.Hash, callback, handle); }
public void RegisterFactory(Type type, string category = "") { if (!type.IsSubclassOf(typeof(Object))) { throw new ArgumentException("Type must be subclass of Object."); } _factoryTypes[StringHash.Calculate(type.Name)] = type; // Find a wrapper base type. var baseType = type.BaseType; while (baseType != null && baseType.Assembly != typeof(Context).Assembly) { baseType = baseType.BaseType; } if (baseType == null) { throw new InvalidOperationException("This type can not be registered as factory."); } Urho3D_Context_RegisterFactory(getCPtr(this), type.Name, StringHash.Calculate("SwigDirector_" + baseType.Name), category); if (type.IsSubclassOf(typeof(Serializable))) { using (var serializable = (Serializable)Activator.CreateInstance(type, new object[] { Context.Instance })) { serializable.RegisterAttributes(); } } }
public void SubscribeToEvent(StringHash e, Object sender, Action <StringHash, VariantMap> eventHandler) { var eventCallback = new EventCallbackDelegate((eventHash, argMap) => { eventHandler(new StringHash(eventHash), VariantMap.wrap(argMap, false)); }); var handle = GCHandle.ToIntPtr(GCHandle.Alloc(eventCallback)); var callback = Marshal.GetFunctionPointerForDelegate(eventCallback); Urho3D_Object_SubscribeToEvent(swigCPtr, getCPtr(sender), e.Hash, callback, handle); }
public void RegisterFactory(Type type, string category = "") { if (!type.IsSubclassOf(typeof(Object))) { throw new ArgumentException("Type must be subclass of Object."); } _factoryTypes[StringHash.Calculate(type.Name)] = type; // Find a wrapper base type. var baseType = type.BaseType; while (baseType != null && baseType.Assembly != typeof(Context).Assembly) { baseType = baseType.BaseType; } if (baseType == null) { throw new InvalidOperationException("This type can not be registered as factory."); } Urho3D_Context_RegisterFactory(getCPtr(this), type.Name, StringHash.Calculate("SwigDirector_" + baseType.Name), category); }
public void SubscribeToEvent(StringHash e, Action <VariantMap> eventHandler) { SubscribeToEvent(e, null, eventHandler); }
public void SubscribeToEvent(StringHash e, Object sender, Action <VariantMap> eventHandler) { SubscribeToEvent(e, sender, (evt, args) => eventHandler(args)); }
internal static uint GetNativeInstance(StringHash source) { return(source.Hash); }