예제 #1
0
        private static void DrawElement(Rect rect, int index, bool active, bool focused)
        {
            var el = _currentReorderedList[index];

            var selected = GetIsSelected(index);

            var after = EditorGUI.Toggle(new Rect(rect.x, rect.y, 30, rect.height), selected);

            if (after != selected)
            {
                SetIsSelected(index, after);
            }

            rect.x     += 30;
            rect.width -= 30;

            if (el != null)
            {
                var ty = el.GetType();

                textAndToolTip.text    = ty.ToString();
                textAndToolTip.tooltip = el.ToPegiString();


                var uo = el as Object;
                if (uo)
                {
                    var mb = uo as Component;
                    var go = mb ? mb.gameObject : uo as GameObject;

                    if (!go)
                    {
                        EditorGUI.ObjectField(rect, textAndToolTip, uo, _currentReorderedType, true);
                    }
                    else
                    {
                        var mbs = go.GetComponents <Component>();

                        if (mbs.Length > 1)
                        {
                            //rect.width = 100;
                            //EditorGUI.ObjectField(rect, cont, uo, _currentReorderedType, true);
                            //rect.x += 100;
                            //rect.width = 100;

                            if (select(ref mb, mbs, rect))
                            {
                                _currentReorderedList[index] = mb;
                            }
                        }
                        else
                        {
                            EditorGUI.ObjectField(rect, textAndToolTip, uo, _currentReorderedType, true);
                        }
                    }
                }
                else
                {
                    if (_currentReorderedListTypes != null)
                    {
                        rect.width = 100;
                        EditorGUI.LabelField(rect, textAndToolTip);
                        rect.x    += 100;
                        rect.width = 100;

                        if (select_Type(ref ty, _currentReorderedListTypes, rect))
                        {
                            _currentReorderedList.TryChangeObjectType(index, ty, _listMetaData);
                        }
                    }
                    else
                    {
                        EditorGUI.LabelField(rect, textAndToolTip);
                    }
                }
            }
            else
            {
                var ed = _listMetaData.TryGetElement(index);

                if (ed != null && ed.unrecognized)
                {
                    if (_currentTaggedTypes != null)
                    {
                        textAndToolTip.text    = "UNREC {0}".F(ed.unrecognizedUnderTag);
                        textAndToolTip.tooltip = "Select New Class";

                        rect.width = 100;
                        EditorGUI.LabelField(rect, textAndToolTip);
                        rect.x    += 100;
                        rect.width = 100;

                        Type ty = null;

                        if (select_Type(ref ty, _currentReorderedListTypes, rect))
                        {
                            el = Activator.CreateInstance(ty);
                            _currentReorderedList[index] = el;

                            var std = el as ICfg;

                            if (std != null)
                            {
                                std.Decode(ed.SetRecognized().stdDta);
                            }
                        }
                    }
                }
                else
                {
                    EditorGUI.LabelField(rect, "Empty {0}".F(_currentReorderedType.ToPegiStringType()));
                }
            }
        }
예제 #2
0
        public static bool TryInspect <T>(this ListMetaData ld, ref T obj, int ind) where T : Object
        {
            var el = ld.TryGetElement(ind);

            return(el?.PEGI_inList_Obj(ref obj) ?? edit(ref obj));
        }