Ejemplo n.º 1
0
 public override void OnEnable()
 {
     base.OnEnable();
     m_PrimaryLibraryGUID = extraDataSerializedObject.FindProperty("m_PrimaryLibraryGUID");
     if (!m_PrimaryLibraryGUID.hasMultipleDifferentValues && !string.IsNullOrEmpty(m_PrimaryLibraryGUID.stringValue))
     {
         var assetPath = AssetDatabase.GUIDToAssetPath(m_PrimaryLibraryGUID.stringValue);
         m_MainSpriteLibraryAsset = AssetDatabase.LoadAssetAtPath <SpriteLibraryAsset>(assetPath);
     }
     m_Library = extraDataSerializedObject.FindProperty("m_Library");
     m_SpriteLibraryDataInspector = new SpriteLibraryDataInspector(extraDataSerializedObject, m_Library);
 }
Ejemplo n.º 2
0
 void DoMainAssetGUI()
 {
     EditorGUI.BeginChangeCheck();
     if (m_PrimaryLibraryGUID.hasMultipleDifferentValues)
         EditorGUI.showMixedValue = true;
     m_MainSpriteLibraryAsset = AssetDatabase.LoadAssetAtPath<SpriteLibraryAsset>(AssetDatabase.GUIDToAssetPath(m_PrimaryLibraryGUID.stringValue));
     m_MainSpriteLibraryAsset = EditorGUILayout.ObjectField(Style.mainAssetLabel, m_MainSpriteLibraryAsset, typeof(SpriteLibraryAsset), false) as SpriteLibraryAsset;
     if (EditorGUI.EndChangeCheck())
     {
         m_PrimaryLibraryGUID.stringValue = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_MainSpriteLibraryAsset));
         SpriteLibraryDataInspector.UpdateLibraryWithNewMainLibrary(m_MainSpriteLibraryAsset, m_Library);
         serializedObject.ApplyModifiedProperties();
     }
     EditorGUI.showMixedValue = false;
 }
Ejemplo n.º 3
0
        void UpdateSpriteLibraryDataCache()
        {
            if (m_MasterLibraryCategories.hasMultipleDifferentValues)
            {
                return;
            }
            if (m_MasterLibraryProperty.hasMultipleDifferentValues)
            {
                return;
            }

            CopySpriteLibraryToOverride(m_OverrideLibraryObject.library, m_MasterLibraryCategories);
            m_OverrideLibraryCache.Update();
            SpriteLibraryDataInspector.UpdateLibraryWithNewMainLibrary(m_MasterLibraryObject, m_OverrideLibraryCategories);
            m_SpriteLibraryDataInspector = new SpriteLibraryDataInspector(serializedObject, m_OverrideLibraryCategories);
            m_OverrideLibraryCache.ApplyModifiedPropertiesWithoutUndo();
        }
 void OnPreprocessAsset()
 {
     if (assetImporter is SpriteLibrarySourceAssetImporter)
     {
         var obj = SpriteLibrarySourceAssetImporter.LoadSpriteLibrarySourceAsset(assetPath);
         if (obj != null)
         {
             SpriteLibraryAsset mainLibraryAsset = null;
             var mainLibraryAssetAssetPath       = AssetDatabase.GUIDToAssetPath(obj.primaryLibraryID);
             mainLibraryAsset = AssetDatabase.LoadAssetAtPath <SpriteLibraryAsset>(mainLibraryAssetAssetPath);
             var so      = new SerializedObject(obj);
             var library = so.FindProperty("m_Library");
             SpriteLibraryDataInspector.UpdateLibraryWithNewMainLibrary(mainLibraryAsset, library);
             if (so.hasModifiedProperties)
             {
                 so.ApplyModifiedPropertiesWithoutUndo();
                 SpriteLibrarySourceAssetImporter.SaveSpriteLibrarySourceAsset(obj, assetPath);
             }
         }
     }
 }