Exemplo n.º 1
0
        SFC.WriteSmartFloat CreateWriteFloat(SFD.FloatVar s)
        {
            var go = new GameObject("WRITER");
            var w  = go.AddComponent <SFC.WriteSmartFloat>();

            var sow = new SerializedObject(w);

            sow.FindProperty("_data").FindPropertyRelative("_smartVar").objectReferenceValue = s;
            sow.ApplyModifiedProperties();
            sow.Update();

            return(w);
        }
Exemplo n.º 2
0
        SFC.ReadSmartFloat CreateReadSmartFloat(SFD.FloatVar s)
        {
            var go = new GameObject("READER");
            var l  = go.AddComponent <SFC.ReadSmartFloat>();

            var sol = new SerializedObject(l);
            var arr = sol.FindProperty("_data");

            arr.arraySize++;
            var el = arr.GetArrayElementAtIndex(0);

            el.FindPropertyRelative("_smartVar").objectReferenceValue = s;
            sol.ApplyModifiedProperties();
            sol.Update();
            var evt = ((UnityEvent <float>)el.FindPropertyRelative("_onUpdate").GetObject());

            evt.AddListener(OnUpdated);
            var fr = (SmartFloat.FloatReader)el.GetObject();

            fr.GetType().GetField("_refType", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(fr, SmartData.Abstract.SmartDataRefBase.RefType.VAR);
            fr.unityEventOnReceive = true;

            return(l);
        }