Пример #1
0
        private void Setup(ParameterInfo[] setParameterInfos, LinkedMemberInfo setMemberInfo, IParentDrawer setParent, GUIContent setLabel, bool setReadOnly)
        {
                        #if DEV_MODE
            if (setReadOnly)
            {
                Debug.LogWarning(StringUtils.ToColorizedString(ToString(), ".Setup - readonly=", true, ". Really don't allow editing parameter value? This is usually desired even for read-only properties."));
            }
                        #endif

            parameterInfos  = setParameterInfos;
            drawInSingleRow = parameterInfos.Length == 1 && DrawerUtility.CanDrawMultipleControlsOfTypeInSingleRow(parameterInfos[0].ParameterType);

            if (setLabel == null)
            {
                setLabel = GUIContentPool.Create("Parameters");
            }

            int count    = parameterInfos.Length;
            var setValue = ArrayPool <object> .Create(count);

            for (int n = count - 1; n >= 0; n--)
            {
                setValue[n] = ParameterValues.GetValue(parameterInfos[n]);
            }

            // always set readonly to false to fix issue where
            // parameters of read-only indexer Properties could not be modified
            base.Setup(setValue, typeof(object[]), setMemberInfo, setParent, setLabel, setReadOnly);
        }
Пример #2
0
        /// <inheritdoc />
        protected override void DoBuildMembers()
        {
            int count = memberBuildList.Count;

                        #if DEV_MODE && PI_ASSERTATIONS
            Debug.Assert(count == parameterInfos.Length, "memberBuildList.Count=" + memberBuildList.Count + " != " + parameterInfos.Length);
                        #endif

                        #if DEV_MODE
            Debug.Log("ParameterDrawer.DoBuildMembers called with parameterInfos.Length=" + parameterInfos.Length + ", memberBuildList.Count=" + memberBuildList.Count + ", drawInSingleRow=" + drawInSingleRow);
                        #endif

            DrawerArrayPool.Resize(ref members, count);

            //If only has one parameter, can be drawn in a single row
            if (drawInSingleRow)
            {
                                #if DEV_MODE && PI_ASSERTATIONS
                Debug.Assert(memberBuildList.Count == 1);
                Debug.Assert(parameterInfos.Length == 1);
                                #endif

                var memberFieldInfo = memberBuildList[0];
                var parameterInfo   = memberFieldInfo.ParameterInfo;
                var type            = GetParameterTypeAndLabel(memberFieldInfo, ref label);

                var member = DrawerProvider.GetForField(ParameterValues.GetValue(parameterInfo), type, memberFieldInfo, this, GUIContent.none, ReadOnly);

                                #if DEV_MODE || SAFE_MODE
                if (member == null)
                {
                    Debug.LogError(ToString() + " Failed to create Drawer for member " + memberFieldInfo + " of type " + StringUtils.ToString(type) + ".\nparent=" + StringUtils.ToString(parent));
                    DrawerArrayPool.Resize(ref members, 0);
                    return;
                }
                                #endif

                //can't draw the member in a single row after all!
                if (!DrawerUtility.CanDrawInSingleRow(member))
                {
                    drawInSingleRow = false;
                    member.Dispose();
                    DoBuildMembers();
                    return;
                }

                members[0] = member;
            }
            else
            {
                for (int n = count - 1; n >= 0; n--)
                {
                    var memberFieldInfo = memberBuildList[n];
                    var parameterInfo   = memberFieldInfo.ParameterInfo;
                    var memberLabel     = GUIContentPool.Empty();
                    var type            = GetParameterTypeAndLabel(memberFieldInfo, ref memberLabel);
                    var member          = DrawerProvider.GetForField(ParameterValues.GetValue(parameterInfo), type, memberFieldInfo, this, memberLabel, ReadOnly);

                                        #if DEV_MODE || SAFE_MODE
                    if (member == null)
                    {
                        for (int d = count - 1; d > n; d--)
                        {
                            members[d].Dispose();
                        }
                        Debug.LogError(ToString() + " Failed to create Drawer for members[" + n + "] " + memberFieldInfo + " of type " + StringUtils.ToString(type) + ".\nparent=" + StringUtils.ToString(parent));
                        DrawerArrayPool.Resize(ref members, 0);
                        return;
                    }
                                        #endif

                    members[n] = member;
                }
            }
        }
Пример #3
0
 public override void GetValue(object fieldOwner, out object result)
 {
     result = ParameterValues.GetValue(parameterInfo);
 }