Esempio n. 1
0
 protected virtual void drawChooseTimeline(GAFAnimationAsset _Asset)
 {
     if (_Asset.getTimelines().Count > 1)
     {
         GUILayout.Space(6f);
         EditorGUILayout.BeginVertical(EditorStyles.textField);
         {
             EditorGUILayout.LabelField("Choose timeline ID:");
             EditorGUILayout.BeginHorizontal();
             {
                 var timelineIDs = _Asset.getTimelines().ConvertAll(timeline => timeline.id.ToString() + (timeline.linkageName.Length > 0 ? " - " + timeline.linkageName : "")).ToArray();
                 var index       = GUILayout.SelectionGrid(m_TimelineIndex, timelineIDs, timelineIDs.Length < 4 ? timelineIDs.Length : 4);
                 if (index != m_TimelineIndex)
                 {
                     m_TimelineIndex = index;
                     var timeline = timelineIDs[index];
                     m_TimelineID = timeline.IndexOf(" - ") > 0 ? int.Parse(timeline.Split('-')[0]) : int.Parse(timeline);
                 }
             }
             EditorGUILayout.EndHorizontal();
         }
         EditorGUILayout.EndVertical();
     }
     else
     {
         GUILayout.Space(6f);
         EditorGUILayout.BeginVertical(EditorStyles.textField);
         {
             EditorGUILayout.LabelField("Timeline ID: 0 - rootTimeline");
             m_TimelineID    = 0;
             m_TimelineIndex = 0;
         }
         EditorGUILayout.EndVertical();
     }
 }
Esempio n. 2
0
        public static void createResources(GAFAnimationAsset _Asset)
        {
            var assetPath = AssetDatabase.GetAssetPath(_Asset);

            if (!string.IsNullOrEmpty(assetPath))
            {
                GAFSystemEditor.getCachePath();

                var assetGUID             = AssetDatabase.AssetPathToGUID(assetPath);
                var resourceTexturesNames = new Dictionary <KeyValuePair <float, float>, List <string> >();

                _Asset.resetGUID(assetGUID);

                foreach (var timeline in _Asset.getTimelines())
                {
                    foreach (var atlas in timeline.atlases)
                    {
                        foreach (var data in atlas.texturesData.Values)
                        {
                            foreach (var textureInfo in data.files)
                            {
                                string textureName = Path.GetFileNameWithoutExtension(textureInfo.Value);
                                var    key         = new KeyValuePair <float, float>(atlas.scale, textureInfo.Key);

                                if (!resourceTexturesNames.ContainsKey(key))
                                {
                                    resourceTexturesNames[key] = new List <string>();
                                }

                                resourceTexturesNames[key].Add(textureName);
                            }
                        }
                    }
                }

                m_Resources.RemoveAll(resource => resource == null || !resource.isValid);

                foreach (var pair in resourceTexturesNames)
                {
                    var name          = _Asset.getResourceName(pair.Key.Key, pair.Key.Value) + ".asset";
                    var path          = GAFSystemEditor.getCachePath() + name;
                    var initialResDir = Path.GetDirectoryName(assetPath).Replace('\\', '/') + "/";

                    var resource = ScriptableObject.CreateInstance <GAFTexturesResource>();
                    resource = GAFAssetUtils.saveAsset(resource, path);
                    resource.initialize(_Asset, pair.Value.Distinct().ToList(), pair.Key.Key, pair.Key.Value, initialResDir);
                    EditorUtility.SetDirty(resource);

                    findResourceTextures(resource, true);

                    if (!resource.isReady)
                    {
                        m_Resources.Add(resource);
                    }
                }

                EditorUtility.SetDirty(_Asset);
            }
        }