コード例 #1
0
        protected override ColliderDistance2D CreateInstanceFromValues(ValuesArray <object> values)
        {
            var instance = new ColliderDistance2D {
                pointA   = values.GetAsTypeOrDefault <Vector2>(0),
                pointB   = values.GetAsTypeOrDefault <Vector2>(1),
                distance = values.GetAsTypeOrDefault <float>(3),
                isValid  = values.GetAsTypeOrDefault <bool>(4),
            };

            if (_normalField == null)
            {
                throw new JsonException("Failed to set value for 'm_Normal' field on UnityEngine.ColliderDistance2D type.");
            }

            Vector2 normal = values.GetAsTypeOrDefault <Vector2>(2);

#if ENABLE_IL2CPP
            object boxed = instance;

            _normalField.SetValue(boxed, normal);

            return((ColliderDistance2D)boxed);
#else
            TypedReference reference = __makeref(instance);

            _normalField.SetValueDirect(reference, normal);

            return(instance);
#endif
        }
コード例 #2
0
 protected override Plane CreateInstanceFromValues(ValuesArray <object> values)
 {
     return(new Plane(
                values.GetAsTypeOrDefault <Vector3>(0),
                values.GetAsTypeOrDefault <float>(1)
                ));
 }
コード例 #3
0
        protected override CullingGroupEvent CreateInstanceFromValues(ValuesArray <object> values)
        {
            if (_indexField is null)
            {
                throw new InvalidOperationException($"Was unable to find index field from the {typeof(CullingGroupEvent).FullName} type.");
            }

            if (_prevStateField is null)
            {
                throw new InvalidOperationException($"Was unable to find prevState field from the {typeof(CullingGroupEvent).FullName} type.");
            }

            if (_thisStateField is null)
            {
                throw new InvalidOperationException($"Was unable to find thisState field from the {typeof(CullingGroupEvent).FullName} type.");
            }

            int  index            = values.GetAsTypeOrDefault <int>(0);
            byte isVisibleByte    = values.GetAsTypeOrDefault <bool>(1) ? (byte)0x80 : (byte)0;
            byte wasVisibleByte   = values.GetAsTypeOrDefault <bool>(2) ? (byte)0x80 : (byte)0;
            byte currentDistance  = values.GetAsTypeOrDefault <byte>(3);
            byte previousDistance = values.GetAsTypeOrDefault <byte>(4);

            int thisStateByte = (byte)(isVisibleByte | (currentDistance & DISTANCE_MASK));
            int prevStateByte = (byte)(wasVisibleByte | (previousDistance & DISTANCE_MASK));

            var            instance  = new CullingGroupEvent();
            TypedReference reference = __makeref(instance);

            _indexField.SetValueDirect(reference, index);
            _prevStateField.SetValueDirect(reference, prevStateByte);
            _thisStateField.SetValueDirect(reference, thisStateByte);

            return(instance);
        }
コード例 #4
0
        protected override NavMeshQueryFilter CreateInstanceFromValues(ValuesArray <object> values)
        {
            var instance = new NavMeshQueryFilter {
                areaMask    = values.GetAsTypeOrDefault <int>(1),
                agentTypeID = values.GetAsTypeOrDefault <int>(2),
            };

            if (values[0] is float[] costs)
            {
                for (int i = 0; i < costs.Length; i++)
                {
                    instance.SetAreaCost(i, costs[i]);
                }
            }

            return(instance);
        }
コード例 #5
0
        protected override ContactFilter2D CreateInstanceFromValues(ValuesArray <object> values)
        {
            return(new ContactFilter2D {
                useTriggers = values.GetAsTypeOrDefault <bool>(0),
                useLayerMask = values.GetAsTypeOrDefault <bool>(1),
                useDepth = values.GetAsTypeOrDefault <bool>(2),
                useOutsideDepth = values.GetAsTypeOrDefault <bool>(3),
                useNormalAngle = values.GetAsTypeOrDefault <bool>(4),
                useOutsideNormalAngle = values.GetAsTypeOrDefault <bool>(5),

                layerMask = values.GetAsTypeOrDefault <LayerMask>(6),

                minDepth = values.GetAsTypeOrDefault <float>(7),
                maxDepth = values.GetAsTypeOrDefault <float>(8),
                minNormalAngle = values.GetAsTypeOrDefault <float>(9),
                maxNormalAngle = values.GetAsTypeOrDefault <float>(10),
            });
        }