Пример #1
0
        private void drawResourceDataList(List <GAFResourceData> _Data)
        {
            foreach (var data in _Data)
            {
                GUILayout.Label(data.name);
                var texture = EditorGUILayout.ObjectField(data.sharedTexture, typeof(Texture2D), false) as Texture2D;
                if (texture != data.sharedTexture)
                {
                    if (texture != null)
                    {
                        var mat = GAFResourceManager.getSharedMaterial(texture);
                        mat.mainTexture = texture;
                        data.set(texture, mat);
                        EditorUtility.SetDirty(mat);
                    }
                    else
                    {
                        data.set(null, null);
                    }

                    EditorUtility.SetDirty(target);
                }

                var material = EditorGUILayout.ObjectField(data.sharedMaterial, typeof(Material), false) as Material;
                if (material != data.sharedMaterial)
                {
                    data.set(data.sharedTexture, material);
                }

                GUILayout.Space(6f);
            }
        }
Пример #2
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUILayout.Space(3f);
            EditorGUILayout.ObjectField(target.asset, typeof(GAFAnimationAsset), false);

            GUILayout.Space(6f);
            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Scale = " + target.scale.ToString());
                GUILayout.Label("Csf = " + target.csf.ToString());
                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(6f);
            GUILayout.Label("* This folder will be used to find missing textures!");
            GAFEditorHelper.drawFolder(
                ref m_DrawPath
                , target.currentDataPath
                , Application.dataPath + "/"
                , "Data directory: Assets/"
                , "Select destination folder"
                , (newPath) =>
            {
                relocateResourceData(target, "Assets/" + newPath);
                normalizeDrawPath();
            }
                , () =>
            {
                normalizeDrawPath();
            });

            GUI.enabled = !target.isReady;
            if (GUILayout.Button("Find textures!"))
            {
                GAFResourceManager.findResourceTextures(target, false);
            }
            GUI.enabled = true;

            if (target.data.Count > 0)
            {
                GUILayout.Space(6f);
                GUILayout.Label("Found resource data:");
                GUILayout.Space(3f);
                drawResourceDataList(target.data);
            }

            if (target.missingData.Count > 0)
            {
                GUILayout.Space(6f);
                GUILayout.Label("Not found resource data:");
                GUILayout.Space(3f);
                drawResourceDataList(target.missingData);
            }
        }
Пример #3
0
        public static void OnPostprocessAllAssets(
            string[] importedAssets
            , string[] deletedAssets
            , string[] movedAssets
            , string[] movedFromAssetPaths)
        {
            foreach (string assetName in importedAssets)
            {
                if (assetName.EndsWith(".gaf"))
                {
                    byte[] fileBytes = null;
                    using (BinaryReader freader = new BinaryReader(File.OpenRead(assetName)))
                    {
                        fileBytes = freader.ReadBytes((int)freader.BaseStream.Length);
                    }

                    if (fileBytes.Length > sizeof(int))
                    {
                        int header = System.BitConverter.ToInt32(fileBytes.Take(4).ToArray(), 0);
                        if (GAFHeader.isCorrectHeader((GAFHeader.CompressionType)header))
                        {
                            var path = Path.GetDirectoryName(assetName) + "/" + Path.GetFileNameWithoutExtension(assetName) + ".asset";

                            var asset = AssetDatabase.LoadAssetAtPath(path, typeof(GAFAnimationAsset)) as GAFAnimationAsset;
                            if (asset == null)
                            {
                                asset = ScriptableObject.CreateInstance <GAFAnimationAsset>();
                                asset = GAFAssetUtils.saveAsset(asset, path);
                            }

                            asset.name = Path.GetFileNameWithoutExtension(assetName);
                            asset.initialize(fileBytes, AssetDatabase.AssetPathToGUID(path));
                            EditorUtility.SetDirty(asset);
                            GAFResourceManager.createResources(asset);

                            GAFTracking.sendAssetCreatedRequest(assetName);
                        }
                    }
                }
            }
        }
Пример #4
0
 public void OnPostprocessTexture(Texture2D _Texture)
 {
     GAFResourceManager.postProcessTexture(assetPath, (TextureImporter)assetImporter);
 }
Пример #5
0
 public void OnPreprocessTexture()
 {
     GAFResourceManager.preProcessTexture((TextureImporter)assetImporter);
 }
Пример #6
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            var nameProperty = serializedObject.FindProperty("m_Name");

            GUILayout.Space(5f);
            EditorGUILayout.LabelField("Asset name: " + (!nameProperty.hasMultipleDifferentValues ? nameProperty.stringValue : "—"), EditorStyles.boldLabel);

            var loadedCount = targets.Where(_target => _target.isLoaded).Count();

            if (loadedCount == targets.Count)
            {
                if (loadedCount == 1)
                {
                    drawAssetData();

                    GUILayout.Space(5f);
                    drawTimelines();

                    GUILayout.Space(5f);
                    drawCreateClip();

                    GUILayout.Space(10f);
                    drawAnimationColor();

                    GUILayout.Space(10f);
                    drawResources();
                }
                else
                {
                    GUILayout.Space(5f);
                    EditorGUILayout.HelpBox("Cannot view multiple asset settings.", MessageType.Info);

                    GUILayout.Space(5f);
                    drawCreateClip();
                }
            }
            else if (loadedCount == 0)
            {
                GUILayout.Space(5f);
                EditorGUILayout.HelpBox("Asset(s) is(are) not loaded! Please reload asset(s) or reimport '.gaf' file.", MessageType.Warning);
            }
            else
            {
                GUILayout.Space(5f);
                EditorGUILayout.HelpBox("Some of assets are not loaded! Please reload asset(s) or reimport '.gaf' file.", MessageType.Warning);
            }

            GUI.enabled = loadedCount == targets.Count;
            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Delete resources"))
                {
                    foreach (var _target in targets)
                    {
                        GAFResourceManager.deleteResources(_target);
                    }
                }

                if (GUILayout.Button("Rebuild resources"))
                {
                    foreach (var _target in targets)
                    {
                        GAFResourceManager.createResources(_target);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;
        }