예제 #1
0
 public override void SetValue(ref object fieldOwner, object value)
 {
     ParameterValues.CacheValue(parameterInfo, value);
 }
예제 #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);
 }