private void OnAlloyImport(Texture2D texture, OnAlloyImportFunc onImport) {
            // Check to see if this is an Alloy material that we need to edit.
            if (!IsAlloyPackedMapPath(assetPath)) {
                return;
            }

            // and if we've got saved settings/data for it...
            var textureName = Path.GetFileNameWithoutExtension(assetPath);
            var path = Path.Combine(Path.GetDirectoryName(assetPath), textureName) + ".asset";

            //Import can fail because of a variety of reasons, so make sure it's all good here
            if (!File.Exists(path)) {
                Debug.LogError(textureName + " has no post-processing data! Please contact Alloy support.");
                Selection.activeObject = texture;
                return;
            }

            var settings = AssetDatabase.LoadAssetAtPath(path, typeof (AlloyCustomImportObject)) as AlloyCustomImportObject;
            if (settings == null) {
                if (AlloyImporterSupervisor.IsFinalTry) {
                    Debug.LogError(textureName + " settings file is corrupt! Contact Alloy support");
                    return;
                }

                AlloyImporterSupervisor.OnFailedImport(path);
                return;
            }

            for (int i = 0; i < 4; ++i) {
                if (settings.SelectedModes[i] == TextureValueChannelMode.Texture && settings.GetTexture(i) == null) {
                    if (AlloyImporterSupervisor.IsFinalTry) {
                        Debug.LogError(textureName + " texture input " + (i + 1) + " can't be loaded!");
                        return;
                    }

                    AlloyImporterSupervisor.OnFailedImport(path);
                    return;
                }
            }

            if (!string.IsNullOrEmpty(settings.NormalGUID) && settings.NormalMapTexture == null) {
                if (AlloyImporterSupervisor.IsFinalTry) {
                    Debug.LogError(textureName + " normalmap texture input can't be loaded!");
                    return;
                }

                AlloyImporterSupervisor.OnFailedImport(path);
                return;
            }

            //If it's all good, do the importing action
            onImport(settings, texture, path);
        }
Esempio n. 2
0
        private void OnAlloyImport(Texture2D texture, OnAlloyImportFunc onImport)
        {
            // Check to see if this is an Alloy material that we need to edit.
            if (!IsAlloyPackedMapPath(assetPath))
            {
                return;
            }

            // and if we've got saved settings/data for it...
            var textureName = Path.GetFileNameWithoutExtension(assetPath);
            var path        = Path.Combine(Path.GetDirectoryName(assetPath), textureName) + ".asset";

            //Import can fail because of a variety of reasons, so make sure it's all good here
            if (!File.Exists(path))
            {
                Debug.LogError(textureName + " has no post-processing data! Please contact Alloy support.");
                Selection.activeObject = texture;
                return;
            }

            var settings = AssetDatabase.LoadAssetAtPath(path, typeof(AlloyCustomImportObject)) as AlloyCustomImportObject;

            if (settings == null)
            {
                if (AlloyImporterSupervisor.IsFinalTry)
                {
                    Debug.LogError(textureName + " settings file is corrupt! Contact Alloy support");
                    return;
                }

                AlloyImporterSupervisor.OnFailedImport(path);
                return;
            }

            for (int i = 0; i < 4; ++i)
            {
                if (settings.SelectedModes[i] == TextureValueChannelMode.Texture && settings.GetTexture(i) == null)
                {
                    if (AlloyImporterSupervisor.IsFinalTry)
                    {
                        Debug.LogError(textureName + " texture input " + (i + 1) + " can't be loaded!");
                        return;
                    }

                    AlloyImporterSupervisor.OnFailedImport(path);
                    return;
                }
            }

            if (!string.IsNullOrEmpty(settings.NormalGUID) && settings.NormalMapTexture == null)
            {
                if (AlloyImporterSupervisor.IsFinalTry)
                {
                    Debug.LogError(textureName + " normalmap texture input can't be loaded!");
                    return;
                }

                AlloyImporterSupervisor.OnFailedImport(path);
                return;
            }

            //If it's all good, do the importing action
            onImport(settings, texture, path);
        }