コード例 #1
0
        public void LoadPrefs()
        {
            if (prefs == null)
            {
                prefs = new EditorRecord();
            }
            else
            {
                foreach (var x in prefs)
                {
                    switch (x.Value.Type)
                    {
                    case RecordValueType.Int:
                        prefs[x.Key] = EditorPrefs.GetInt(x.Key.ToString(), 0);
                        break;

                    case RecordValueType.Float:
                        prefs[x.Key] = EditorPrefs.GetFloat(x.Key.ToString(), 0.0f);
                        break;

                    case RecordValueType.String:
                        prefs[x.Key] = EditorPrefs.GetString(x.Key.ToString(), string.Empty);
                        break;

                    case RecordValueType.Bool:
                        prefs[x.Key] = EditorPrefs.GetBool(x.Key.ToString(), false);
                        break;
                    }
                }
            }
        }
コード例 #2
0
        public void LoadPrefs()
        {
            if (prefs == null)
            {
                prefs = new EditorRecord();
            }
            else
            {
                foreach (var x in prefs)
                {
                    switch (x.Value.Type)
                    {
                        case RecordValueType.Int:
                        prefs[x.Key] = EditorPrefs.GetInt(x.Key.ToString(), 0);
                        break;

                        case RecordValueType.Float:
                        prefs[x.Key] = EditorPrefs.GetFloat(x.Key.ToString(), 0.0f);
                        break;

                        case RecordValueType.String:
                        prefs[x.Key] = EditorPrefs.GetString(x.Key.ToString(), string.Empty);
                        break;

                        case RecordValueType.Bool:
                        prefs[x.Key] = EditorPrefs.GetBool(x.Key.ToString(), false);
                        break;
                    }
                }
            }
        }
コード例 #3
0
ファイル: BaseDrawer.cs プロジェクト: flatlineteam/relic-rush
        public BaseDrawer Initialize(EditorMember member, Attribute[] attributes, BaseGUI gui, EditorRecord prefs)
        {
            if (attributes == null)
                attributes = Empty;

            if (this.prefs == null)
                this.prefs = prefs;

            this.member     = member;
            this.attributes = attributes;
            this.gui        = gui;

            if (_dynamicFormatter != null)
            {
                _formatArgs[0] = member.Value;
                displayText = _dynamicFormatter(rawTarget, _formatArgs);
            }

            if (_hasInit)
            {
#if DBG
                Log(this + " is Already initialized");
#endif
                return this;
            }
#if DBG
            Log("Initializing: " + this);
#endif
            var displayAttr = attributes.GetAttribute<DisplayAttribute>();
            if (displayAttr != null && MemberDrawersHandler.IsApplicableAttribute(memberType, displayAttr, attributes))
            {
                var hasCustomFormat = !string.IsNullOrEmpty(displayAttr.FormatMethod);
                var formatMethod = hasCustomFormat ? displayAttr.FormatMethod : ("Format" + member.Name);
                var method = targetType.GetMemberFromAll(formatMethod, Flags.StaticInstanceAnyVisibility) as MethodInfo;
                if (method == null)
                {
                    if (hasCustomFormat)
                        Debug.Log("Couldn't find format method: " + displayAttr.FormatMethod);
                }
                else
                {
                    if (method.ReturnType != typeof(string) && method.GetParameters().Length > 0)
                        Debug.Log("Format Method should return a string and take no parameters: " + method);
                    else
                    {
                        _dynamicFormatter = method.DelegateForCall<object, string>();
                        _formatArgs[0] = member.Value;
                        displayText = _dynamicFormatter(rawTarget, _formatArgs);
                    }
                }
            }

            _hasInit = true;
            InternalInitialize();
            Initialize();
            return this;
        }
コード例 #4
0
        private void OnEnable()
        {
            if (prefs == null)
            {
                // TODO CHANGED: A common interface is now used for both cases.
                var t0 = target as IVFWObject;
                if (t0 != null)
                {
                    if (t0.Prefs == null)
                    {
                        t0.Prefs = new EditorRecord();
                    }

                    prefs = t0.Prefs;
                }

                //var t0 = target as BaseBehaviour;
                //if (t0 != null)
                //{
                //    if (t0.Prefs == null)
                //        t0.Prefs = new EditorRecord();

                //    prefs = t0.Prefs;
                //}
                //else
                //{
                //    var t1 = target as BaseScriptableObject;
                //    if (t1 != null)
                //    {
                //        if (t1.Prefs == null)
                //            t1.Prefs = new EditorRecord();

                //        prefs = t1.Prefs;
                //    }
                //}
            }

            var component = target as Component;

            gameObject = component == null ? null : component.gameObject;

            targetType = target.GetType();

            id = RuntimeHelper.GetTargetID(target);

            Initialize();

            var rabbit = gui as RabbitGUI;

            if (rabbit != null && _membersDrawnByUnityLayout.Length > 0)
            {
                rabbit.OnFinishedLayoutReserve = DoUnityLayout;
            }

            gui.OnEnable();
        }
コード例 #5
0
        public TextFilter(string[] values, int id, bool initialToggle, EditorRecord prefs, Action <string> setValue)
        {
            _prefs    = prefs;
            _values   = values;
            _setValue = setValue;
            _id       = RuntimeHelper.CombineHashCodes(id, "Filter");

            _toggle  = _prefs.ValueOrDefault(this._id, initialToggle);
            _pattern = _prefs.ValueOrDefault(this._id, "");
        }
コード例 #6
0
		public void Initialize(MethodInfo method, object rawTarget, UnityObject unityTarget, int id, BaseGUI gui, EditorRecord prefs)
		{
            this.prefs = prefs;
			this.gui = gui;
			this.rawTarget = rawTarget;
            this.unityTarget = unityTarget;
			this.id = id;

			if (initialized) return;
			initialized = true;

            isCoroutine = method.ReturnType == typeof(IEnumerator);

            var commentAttr = method.GetCustomAttribute<CommentAttribute>();
            if (commentAttr != null)
                comment = commentAttr.comment;

			niceName = method.GetNiceName();

            if (niceName.IsPrefix("dbg") || niceName.IsPrefix("Dbg"))
                niceName = niceName.Remove(0, 3);

			invoke	     = method.DelegateForCall();
			var argInfos = method.GetParameters();
			int len      = argInfos.Length;
			argValues    = new object[len];
			argKeys      = new int[len];
			argMembers   = new EditorMember[len];

			for (int iLoop = 0; iLoop < len; iLoop++)
			{
				int i = iLoop;
				var argInfo = argInfos[i];

				argKeys[i] = RuntimeHelper.CombineHashCodes(id, argInfo.ParameterType.Name + argInfo.Name);

				argValues[i] = TryLoad(argInfos[i].ParameterType, argKeys[i]);

                argMembers[i] = EditorMember.WrapGetSet(
                        @get         : () =>  argValues[i],
                        @set         : x => argValues[i] = x,
                        @rawTarget   : rawTarget,
                        @unityTarget : unityTarget,
                        @attributes  : argInfo.GetCustomAttributes(true) as Attribute[],
                        @name        : argInfo.Name,
                        @id          : argKeys[i],
                        @dataType    : argInfo.ParameterType
                    );
			}

#if DBG
			Log("Method drawer init");
#endif
		}
コード例 #7
0
        public MembersCategory(string fullPath, float displayOrder, int id, EditorRecord prefs)
        {
            _prefs            = prefs;
            this.DisplayOrder = displayOrder;
            this.FullPath     = fullPath;
            this.Name         = FullPath.Substring(FullPath.LastIndexOf('/') + 1);
            this._id          = RuntimeHelper.CombineHashCodes(id, fullPath.GetHashCode());
            Indent            = true;

            NestedCategories = new List <MembersCategory>();
            Members          = new List <MemberInfo>();
        }
コード例 #8
0
        public RabbitGUI(EditorRecord prefs)
        {
            _currentPhase = GUIPhase.Layout;
            _controls     = new List <GUIControl>();
            _blocks       = new List <GUIBlock>();
            _blockStack   = new Stack <GUIBlock>();
            this.prefs    = prefs;

            #if dbg_level_1
            Debug.Log("Instantiated Rabbit");
            #endif
        }
コード例 #9
0
        public MembersCategory(string fullPath, float displayOrder, int id, EditorRecord prefs)
        {
            _prefs = prefs;
            this.DisplayOrder = displayOrder;
            this.FullPath = fullPath;
            this.Name = FullPath.Substring(FullPath.LastIndexOf('/') + 1);
            this._id = RuntimeHelper.CombineHashCodes(id, fullPath.GetHashCode());
            Indent = true;

            NestedCategories = new List<MembersCategory>();
            Members = new List<MemberInfo>();
        }
コード例 #10
0
        private void OnEnable()
        {
            if (prefs == null)
            {
                var t0 = target as BaseBehaviour;
                if (t0)
                {
                    if (t0.Prefs == null)
                    {
                        t0.Prefs = new EditorRecord();
                    }

                    prefs = t0.Prefs;
                }
                else
                {
                    var t1 = target as BaseScriptableObject;
                    if (t1)
                    {
                        if (t1.Prefs == null)
                        {
                            t1.Prefs = new EditorRecord();
                        }

                        prefs = t1.Prefs;
                    }
                }
            }

            var component = target as Component;

            gameObject = component == null ? null : component.gameObject;

            targetType = target.GetType();

            id = RuntimeHelper.GetTargetID(target);

            Initialize();

            var rabbit = gui as RabbitGUI;

            if (rabbit != null && _membersDrawnByUnityLayout.Length > 0)
            {
                rabbit.OnFinishedLayoutReserve = DoUnityLayout;
            }

            gui.OnEnable();
        }
コード例 #11
0
ファイル: MethodDrawer.cs プロジェクト: if1live/VFW
        public void Initialize(MethodInfo method, object rawTarget, UnityObject unityTarget, int id, BaseGUI gui, EditorRecord prefs)
        {
            this.prefs       = prefs;
            this.gui         = gui;
            this.rawTarget   = rawTarget;
            this.unityTarget = unityTarget;
            this.id          = id;

            if (initialized)
            {
                return;
            }
            initialized = true;

            isCoroutine = method.ReturnType == typeof(IEnumerator);

            var commentAttr = MemberInfoExtensions.GetCustomAttribute <CommentAttribute>(method);

            if (commentAttr != null)
            {
                comment = commentAttr.comment;
            }

            niceName = method.GetNiceName();

            if (niceName.IsPrefix("dbg") || niceName.IsPrefix("Dbg"))
            {
                niceName = niceName.Remove(0, 3);
            }

            invoke = method.DelegateForCall();
            var argInfos = method.GetParameters();
            int len      = argInfos.Length;

            argValues  = new object[len];
            argKeys    = new int[len];
            argMembers = new EditorMember[len];

            for (int iLoop = 0; iLoop < len; iLoop++)
            {
                int i       = iLoop;
                var argInfo = argInfos[i];

                argKeys[i] = RuntimeHelper.CombineHashCodes(id, argInfo.ParameterType.Name + argInfo.Name);

                argValues[i] = TryLoad(argInfos[i].ParameterType, argKeys[i]);

                argMembers[i] = EditorMember.WrapGetSet(
                    @get: () => argValues[i],
                    @set: x => argValues[i] = x,
                    @rawTarget: rawTarget,
                    @unityTarget: unityTarget,
                    @attributes: argInfo.GetCustomAttributes(true) as Attribute[],
                    @name: argInfo.Name,
                    @id: argKeys[i],
                    @dataType: argInfo.ParameterType
                    );
            }

#if DBG
            Log("Method drawer init");
#endif
        }
コード例 #12
0
 public TextFilter(string[] values, int id, EditorRecord prefs, Action <string> setValue)
     : this(values, id, true, prefs, setValue)
 {
 }
コード例 #13
0
ファイル: BaseEditor.cs プロジェクト: flatlineteam/relic-rush
        private void OnEnable()
        {
            if (prefs == null)
            {
                var t0 = target as BaseBehaviour;
                if (t0)
                {
                    if (t0.Prefs == null)
                        t0.Prefs = new EditorRecord();

                    prefs = t0.Prefs;
                }
                else
                {
                    var t1 = target as BaseScriptableObject;
                    if (t1)
                    {
                        if (t1.Prefs == null)
                            t1.Prefs = new EditorRecord();

                        prefs = t1.Prefs;
                    }
                }
            }

            var component = target as Component;
            gameObject = component == null ? null : component.gameObject;

            targetType = target.GetType();

            id = RuntimeHelper.GetTargetID(target);

            Initialize();

            var rabbit = gui as RabbitGUI;
            if (rabbit != null && _membersDrawnByUnityLayout.Length > 0)
                rabbit.OnFinishedLayoutReserve = DoUnityLayout;

            gui.OnEnable();
        }
コード例 #14
0
        public BaseDrawer Initialize(EditorMember member, Attribute[] attributes, BaseGUI gui, EditorRecord prefs)
        {
            if (attributes == null)
            {
                attributes = Empty;
            }

            if (this.prefs == null)
            {
                this.prefs = prefs;
            }

            this.member     = member;
            this.attributes = attributes;
            this.gui        = gui;

            if (_dynamicFormatter != null)
            {
                _formatArgs[0] = member.Value;
                displayText    = _dynamicFormatter(rawTarget, _formatArgs);
            }

            if (_hasInit)
            {
#if DBG
                Log(this + " is Already initialized");
#endif
                return(this);
            }
#if DBG
            Log("Initializing: " + this);
#endif
            var displayAttr = attributes.GetAttribute <DisplayAttribute>();
            if (displayAttr != null && MemberDrawersHandler.IsApplicableAttribute(memberType, displayAttr, attributes))
            {
                var hasCustomFormat = !string.IsNullOrEmpty(displayAttr.FormatMethod);
                var formatMethod    = hasCustomFormat ? displayAttr.FormatMethod : ("Format" + member.Name);
                var method          = targetType.GetMemberFromAll(formatMethod, Flags.StaticInstanceAnyVisibility) as MethodInfo;
                if (method == null)
                {
                    if (hasCustomFormat)
                    {
                        Debug.Log("Couldn't find format method: " + displayAttr.FormatMethod);
                    }
                }
                else
                {
                    if (method.ReturnType != typeof(string) && method.GetParameters().Length > 0)
                    {
                        Debug.Log("Format Method should return a string and take no parameters: " + method);
                    }
                    else
                    {
                        _dynamicFormatter = method.DelegateForCall <object, string>();
                        _formatArgs[0]    = member.Value;
                        displayText       = _dynamicFormatter(rawTarget, _formatArgs);
                    }
                }
            }

            _hasInit = true;
            InternalInitialize();
            Initialize();
            return(this);
        }