Esempio n. 1
0
        private void OnValidate()
        {
            // Make sure error exists
            if (Array.IndexOf(_LogTypes, ManagedLog.Type.Error) < 0)
            {
                var cloned = new ManagedLog.Type[_LogTypes.Length + 1];
                Array.Copy(_LogTypes, 0, cloned, 1, _LogTypes.Length);
                cloned[0] = ManagedLog.Type.Error;
                _LogTypes = cloned;
            }

            // Make sure default exists
            if (Array.IndexOf(_LogTypes, ManagedLog.Type.Default) < 0)
            {
                var cloned = new ManagedLog.Type[_LogTypes.Length + 1];
                Array.Copy(_LogTypes, 0, cloned, 1, _LogTypes.Length);
                cloned[0] = ManagedLog.Type.Default;
                _LogTypes = cloned;
            }

            // Increment last added Type
            var enumLength = Enum.GetNames(typeof(ManagedLog.Type)).Length;
            var offset     = 0;

            while (_LogTypes.Count(type => type == _LogTypes[_LogTypes.Length - 1]) > 1 && offset < enumLength - 1)
            {
                offset++;
                _LogTypes[_LogTypes.Length - 1] =
                    (ManagedLog.Type)offset;
            }

            // Last check that no type repeats in array
            _LogTypes = _LogTypes.Distinct().ToArray();
        }
 protected void LogMethod(object obj = null, ManagedLog.Type type = ManagedLog.Type.Default, Object context = null) => ManagedLog.LogMethod(obj: obj, type: type, context: context, stackOffset: 1);
        // Disabled for now

        /*
         #region Access Restriction
         *
         * // ReSharper disable once InconsistentNaming
         * public new GameObject gameObject
         * {
         *  get
         *  {
         *      Debug.LogWarning($"Shouldn't access {nameof(gameObject)} of {nameof(ControllerBase)}");
         *      return base.gameObject;
         *  }
         * }
         *
         * // ReSharper disable once InconsistentNaming
         * public new Transform transform
         * {
         *  get
         *  {
         *
         *      Debug.LogWarning($"Shouldn't access {nameof(transform)} of {nameof(ControllerBase)}");
         *      return base.transform;
         *  }
         * }
         *
         * // ReSharper disable once InconsistentNaming
         * public new bool enabled
         * {
         *  get
         *  {
         *      Debug.LogWarning($"Shouldn't access {nameof(enabled)} of {nameof(ControllerBase)}");
         *      return base.enabled;
         *  }
         *  set
         *  {
         *      Debug.LogWarning($"Shouldn't access {nameof(enabled)} of {nameof(ControllerBase)}");
         *      base.enabled = value;
         *  }
         * }
         *
         #endregion
         */

        #region Logging Helper Methods

        protected void Log(object obj, ManagedLog.Type type = ManagedLog.Type.Default, Object context = null) => ManagedLog.Log(obj, type, context ? context : this);