Пример #1
0
        private bool CanInitializeNewObject()
        {
#if UNITY_EDITOR || !NETFX_CORE
            if (BoundVariableType.IsAbstract || BoundVariableType.IsInterface)
#else
            if (BoundVariableType.GetTypeInfo().IsAbstract || BoundVariableType.GetTypeInfo().IsInterface)
#endif
            { return(false); }

            if (typeof(ScriptableObject).IsAssignableFrom(BoundVariableType))
            {
                return(true);
            }

            if (typeof(UnityEngine.Object).IsAssignableFrom(BoundVariableType))
            {
                return(false);
            }

            if (BoundVariableType.IsArray)
            {
                return(false);
            }

#if UNITY_EDITOR || !NETFX_CORE
            if (BoundVariableType.IsGenericType && BoundVariableType.GetGenericTypeDefinition() == typeof(List <>))
#else
            if (BoundVariableType.GetTypeInfo().IsGenericType&& BoundVariableType.GetGenericTypeDefinition() == typeof(List <>))
#endif
            { return(false); }

            return(true);
        }
Пример #2
0
        private void RefreshValue()
        {
            try
            {
                m_value = getter();
            }
            catch
            {
#if UNITY_EDITOR || !NETFX_CORE
                if (BoundVariableType.IsValueType)
#else
                if (BoundVariableType.GetTypeInfo().IsValueType)
#endif
                { m_value = Activator.CreateInstance(BoundVariableType); }
                else
                {
                    m_value = null;
                }
            }
        }