예제 #1
0
        public void SaveLabels()
        {
            if (!this.m_CurrentChanged || this.m_AssetLabels == null || this.m_CurrentAssetsSet == null)
            {
                return;
            }
            bool flag1 = false;

            using (HashSet <UnityEngine.Object> .Enumerator enumerator = this.m_CurrentAssetsSet.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    UnityEngine.Object current = enumerator.Current;
                    bool          flag2        = false;
                    List <string> list         = ((IEnumerable <string>)AssetDatabase.GetLabels(current)).ToList <string>();
                    if (this.m_ChangeWasAdd)
                    {
                        if (!list.Contains(this.m_ChangedLabel))
                        {
                            list.Add(this.m_ChangedLabel);
                            flag2 = true;
                        }
                    }
                    else if (list.Contains(this.m_ChangedLabel))
                    {
                        list.Remove(this.m_ChangedLabel);
                        flag2 = true;
                    }
                    if (flag2)
                    {
                        AssetDatabase.SetLabels(current, list.ToArray());
                        if (LabelGUI.s_AssetLabelsForObjectChangedDelegates != null)
                        {
                            this.m_IgnoreNextAssetLabelsChangedCall = true;
                            LabelGUI.s_AssetLabelsForObjectChangedDelegates(current);
                        }
                        flag1 = true;
                    }
                }
            }
            if (flag1)
            {
                EditorApplication.Internal_CallAssetLabelsHaveChanged();
            }
            this.m_CurrentChanged = false;
        }
예제 #2
0
 public void SaveLabels()
 {
     if (this.m_CurrentChanged && this.m_AssetLabels != null && this.m_CurrentAssetsSet != null)
     {
         bool flag = false;
         foreach (UnityEngine.Object current in this.m_CurrentAssetsSet)
         {
             bool          flag2  = false;
             string[]      labels = AssetDatabase.GetLabels(current);
             List <string> list   = labels.ToList <string>();
             if (this.m_ChangeWasAdd)
             {
                 if (!list.Contains(this.m_ChangedLabel))
                 {
                     list.Add(this.m_ChangedLabel);
                     flag2 = true;
                 }
             }
             else
             {
                 if (list.Contains(this.m_ChangedLabel))
                 {
                     list.Remove(this.m_ChangedLabel);
                     flag2 = true;
                 }
             }
             if (flag2)
             {
                 AssetDatabase.SetLabels(current, list.ToArray());
                 if (LabelGUI.s_AssetLabelsForObjectChangedDelegates != null)
                 {
                     this.m_IgnoreNextAssetLabelsChangedCall = true;
                     LabelGUI.s_AssetLabelsForObjectChangedDelegates(current);
                 }
                 flag = true;
             }
         }
         if (flag)
         {
             EditorApplication.Internal_CallAssetLabelsHaveChanged();
         }
         this.m_CurrentChanged = false;
     }
 }
예제 #3
0
 public void SaveLabels()
 {
     if (m_CurrentChanged && m_AssetLabels != null && m_CurrentAssetsSet != null)
     {
         bool anyLabelsWereChanged = false;
         foreach (var currentAsset in m_CurrentAssetsSet)
         {
             bool          currentAssetWasChanged = false; // when multi-editing, some assets might e.g. already have the label that was added to all
             string[]      currentLabels          = AssetDatabase.GetLabels(currentAsset);
             List <string> currentLabelList       = currentLabels.ToList <string>();
             if (m_ChangeWasAdd)
             {
                 if (!currentLabelList.Contains(m_ChangedLabel))
                 {
                     currentLabelList.Add(m_ChangedLabel);
                     currentAssetWasChanged = true;
                 }
             }
             else
             {
                 if (currentLabelList.Contains(m_ChangedLabel))
                 {
                     currentLabelList.Remove(m_ChangedLabel);
                     currentAssetWasChanged = true;
                 }
             }
             if (currentAssetWasChanged)
             {
                 AssetDatabase.SetLabels(currentAsset, currentLabelList.ToArray());
                 if (s_AssetLabelsForObjectChangedDelegates != null)
                 {
                     m_IgnoreNextAssetLabelsChangedCall = true;
                     s_AssetLabelsForObjectChangedDelegates(currentAsset);
                 }
                 anyLabelsWereChanged = true;
             }
         }
         if (anyLabelsWereChanged)
         {
             EditorApplication.Internal_CallAssetLabelsHaveChanged();
         }
         m_CurrentChanged = false;
     }
 }