示例#1
0
        /// <summary>
        ///     Constructor will create the key to store in the EditorPref the state given generic type passed.
        ///     The key will be formated as such prefix:TTarget:TState:UI_State.
        /// </summary>
        /// <param name="defaultValue">If key did not exist, it will be created with this value for initialization.</param>
        /// <param name="prefix">[Optional] Prefix scope of the key (Default is CoreRP)</param>
        public ExpandedState(TState defaultValue, string prefix = "CoreRP")
        {
            string key = $"{prefix}:{typeof(TTarget).Name}:{typeof(TState).Name}:UI_State";

            m_State = new EditorPrefBoolFlags <TState>(key);

            //register key if not already there
            if (!EditorPrefs.HasKey(key))
            {
                EditorPrefs.SetInt(key, (int)(object)defaultValue);
            }
        }
        /// <summary>Constructor will create the key to store in the EditorPref the state given generic type passed.</summary>
        /// <param name="defaultValue">If key did not exist, it will be created with this value for initialization.</param>
        /// <param name="prefix">[Optional] Prefix scope of the key (Default is CoreRP)</param>
        public ExpandedState(TState defaultValue, string prefix = "CoreRP")
        {
            String Key = string.Format("{0}:{1}:UI_State", prefix, typeof(TTarget).Name);

            m_State = new EditorPrefBoolFlags <TState>(Key);

            //register key if not already there
            if (!EditorPrefs.HasKey(Key))
            {
                EditorPrefs.SetInt(Key, (int)(object)defaultValue);
            }
        }