Esempio n. 1
0
        private static void UnserializedPropertyFieldGUILayout <T>(object target, string propertyName, string label, OnGUIDelegate <T> onGUI)
        {
            T currentValue = ReflectionUtils.GetPropertyValue <T>(target, propertyName);
            T newValue     = onGUI(label, currentValue);

            if (!Equals(newValue, currentValue))
            {
                ReflectionUtils.SetPropertyValue(target, propertyName, newValue);
            }
        }
Esempio n. 2
0
        public LightingExplorerTableColumn(DataType type, GUIContent headerContent, string propertyName = null, int width = 100, OnGUIDelegate onGUIDelegate = null, ComparePropertiesDelegate compareDelegate = null, CopyPropertiesDelegate copyDelegate = null, int[] dependencyIndices = null)
        {
            m_Column = new SerializedPropertyTreeView.Column();

            m_Column.headerContent     = headerContent;
            m_Column.width             = width;
            m_Column.minWidth          = width / 2;
            m_Column.propertyName      = propertyName;
            m_Column.dependencyIndices = dependencyIndices;

            m_Column.sortedAscending       = true;
            m_Column.sortingArrowAlignment = TextAlignment.Center;
            m_Column.autoResize            = false;
            m_Column.allowToggleVisibility = true;
            m_Column.headerTextAlignment   = type == DataType.Checkbox ? TextAlignment.Center : TextAlignment.Left;

            switch (type)
            {
            case DataType.Name:
                m_Column.compareDelegate = SerializedPropertyTreeView.DefaultDelegates.CompareName;
                m_Column.drawDelegate    = SerializedPropertyTreeView.DefaultDelegates.DrawName;
                m_Column.filter          = new SerializedPropertyFilters.Name();
                break;

            case DataType.Checkbox:
                m_Column.compareDelegate = SerializedPropertyTreeView.DefaultDelegates.CompareCheckbox;
                m_Column.drawDelegate    = SerializedPropertyTreeView.DefaultDelegates.DrawCheckbox;
                break;

            case DataType.Enum:
                m_Column.compareDelegate = SerializedPropertyTreeView.DefaultDelegates.CompareEnum;
                m_Column.drawDelegate    = SerializedPropertyTreeView.DefaultDelegates.DrawDefault;
                break;

            case DataType.Int:
                m_Column.compareDelegate = SerializedPropertyTreeView.DefaultDelegates.CompareInt;
                m_Column.drawDelegate    = SerializedPropertyTreeView.DefaultDelegates.DrawDefault;
                break;

            case DataType.Float:
                m_Column.compareDelegate = SerializedPropertyTreeView.DefaultDelegates.CompareFloat;
                m_Column.drawDelegate    = SerializedPropertyTreeView.DefaultDelegates.DrawDefault;
                break;

            case DataType.Color:
                m_Column.compareDelegate = SerializedPropertyTreeView.DefaultDelegates.CompareColor;
                m_Column.drawDelegate    = SerializedPropertyTreeView.DefaultDelegates.DrawDefault;
                break;

            default:
                break;
            }

            if (onGUIDelegate != null)
            {
                // when allowing the user to draw checkboxes, we will make sure that the rect is in the center
                if (type == DataType.Checkbox)
                {
                    m_Column.drawDelegate = (r, prop, dep) => {
                        float off = System.Math.Max(0.0f, ((r.width / 2) - 8));
                        r.x     += off;
                        r.width -= off;
                        onGUIDelegate(r, prop, dep);
                    };
                }
                else
                {
                    m_Column.drawDelegate = new SerializedPropertyTreeView.Column.DrawEntry(onGUIDelegate);
                }
            }

            if (compareDelegate != null)
            {
                m_Column.compareDelegate = new SerializedPropertyTreeView.Column.CompareEntry(compareDelegate);
            }

            if (copyDelegate != null)
            {
                m_Column.copyDelegate = new SerializedPropertyTreeView.Column.CopyDelegate(copyDelegate);
            }
        }
Esempio n. 3
0
 public void LoadValueMethod(MethodInfo method)
 {
     m_guiValueMethod = (OnGUIDelegate)Delegate.CreateDelegate(typeof(OnGUIDelegate), method);
 }