Пример #1
0
        public static SerializedDelegate SerializeDelegate(EventCallback callback, string eventname)
        {
            System.Delegate[]  delegates = callback.GetInvocationList();
            SerializedDelegate serial    = new SerializedDelegate()
            {
                eventname = eventname,
                targets   = new Object[delegates.Length],
                methods   = new string[delegates.Length]
            };

            for (int i = 0; i < delegates.Length; i += 1)
            {
                serial.targets[i] = (UnityEngine.Object)delegates[i].Target;
                serial.methods[i] = delegates[i].Method.Name;
            }

            return(serial);
        }