Ejemplo n.º 1
0
        //生成键值
        private void GenerateStringKey(string prefix, int digit)
        {
            int startNum = 1;
            BaseKeySome <string, Value> tempTaget = m_target as BaseKeySome <string, Value>;
            List <string> currentkeys             = new List <string>();

            if (m_lookHasKey)
            {
                for (int i = 0; i < m_target.Count; i++)
                {
                    if (!string.IsNullOrEmpty(tempTaget.Keys[i]))
                    {
                        currentkeys.Add(tempTaget.Keys[i]);
                    }
                }
            }
            Undo.RecordObject(target, "Change Name");
            for (int i = 0; i < tempTaget.Count; i++)
            {
                if (m_lookHasKey && !string.IsNullOrEmpty(tempTaget.Keys[i]))
                {
                    continue;
                }
                while (true)
                {
                    string key = string.Format("{0}{1:D" + digit + "}", prefix, startNum);
                    startNum++;
                    if (!currentkeys.Contains(key))
                    {
                        tempTaget.Keys[i] = key;
                        currentkeys.Add(key);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 protected virtual void OnEnable()
 {
     m_target = target as BaseKeySome <Key, Value>;
 }