SF.FloatMultiWriter CreateMultiWriter(SFA.SmartBase smart, int multiIndex)
        {
            var r = new SF.FloatMultiWriter();

            SetupFloatRef(r, smart, SFA.SmartDataRefBase.RefType.MULTI, multiIndex);
            return(r);
        }
Exemple #2
0
        public static SmartBase _EDITOR_GetSmartObject(System.Type t, SmartRefBase target, out bool useMultiIndex, out bool writeable)
        {
            SmartBase smart = target._EDITOR_GetSmartObject(out useMultiIndex);

            writeable = target._EDITOR_GetIsWritable();
            return(smart);
        }
        SF.FloatWriter CreateWriter(SFA.SmartBase smart, SFA.SmartDataRefBase.RefType type, int multiIndex = -1)
        {
            var r = new SF.FloatWriter();

            SetupFloatRef(r, smart, type, multiIndex);
            return(r);
        }
        void SetupEventRef(object r, SFA.SmartBase smart, int multiIndex = -1)
        {
            var b = BindingFlags.Instance | BindingFlags.NonPublic;

            try {
                // Will throw for EventMultiReader/Writer but doesn't matter
                r.GetType().GetFieldPrivate("_useMulti", b).SetValue(r, multiIndex >= 0);
            } catch {}

            if (multiIndex >= 0)
            {
                r.GetType().GetFieldPrivate("_smartMulti", b).SetValue(r, smart);
                r.GetType().GetField("_multiIndex", b).SetValue(r, multiIndex);
            }
            else
            {
                r.GetType().GetField("_smartEvent", b).SetValue(r, smart);
            }

            r.GetType().GetFieldPrivate("_onEvent", b).SetValue(r, new UnityEvent());

            if (r is ISerializationCallbackReceiver)
            {
                ((ISerializationCallbackReceiver)r).OnAfterDeserialize();
            }
            (r as SmartData.Abstract.SmartRefBase).unityEventOnReceive = true;
        }
        SE.EventMultiDispatcher CreateMultiDispatcher(SFA.SmartBase smart, int multiIndex)
        {
            var r = new SE.EventMultiDispatcher();

            SetupEventRef(r, smart, multiIndex);
            return(r);
        }
        SE.EventDispatcher CreateDispatcher(SFA.SmartBase smart, int multiIndex = -1)
        {
            var l = new SE.EventDispatcher();

            SetupEventRef(l, smart, multiIndex);
            return(l);
        }
        void SetupFloatRef(object r, SFA.SmartBase smart, SFA.SmartDataRefBase.RefType type, int multiIndex)
        {
            var b = BindingFlags.Instance | BindingFlags.NonPublic;

            r.GetType().GetFieldPrivate(SmartDataRefPropertyDrawer.refPropNames[type], b).SetValue(r, smart);
            try {
                // Will throw for FloatMulti but doesn't matter
                r.GetType().GetFieldPrivate("_refType", b).SetValue(r, type);
            } catch {}
            if (multiIndex >= 0)
            {
                r.GetType().GetField("_multiIndex", b).SetValue(r, multiIndex);
            }

            r.GetType().GetFieldPrivate("_onUpdate", b).SetValue(r, new SmartFloat.Data.FloatVar.FloatEvent());

            if (r is ISerializationCallbackReceiver)
            {
                ((ISerializationCallbackReceiver)r).OnAfterDeserialize();
            }
            (r as SmartData.Abstract.SmartRefBase).unityEventOnReceive = true;
        }