Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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();
                }
            }
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 public void SubscribeToEvent(StringHash e, Action <VariantMap> eventHandler)
 {
     SubscribeToEvent(e, null, eventHandler);
 }
Ejemplo n.º 6
0
 public void SubscribeToEvent(StringHash e, Object sender, Action <VariantMap> eventHandler)
 {
     SubscribeToEvent(e, sender, (evt, args) => eventHandler(args));
 }
Ejemplo n.º 7
0
 internal static uint GetNativeInstance(StringHash source)
 {
     return(source.Hash);
 }