Exemple #1
0
        private void OnGUI()
        {
            GUIContent content = new GUIContent("Export Path");

            Rect controlRect = EditorGUILayout.GetControlRect();

            // Rect labelRect = controlRect;
            //labelRect.xMax -= 20;
            //EditorGUI.LabelField(labelRect, _headerContent, EditorStyles.boldLabel);
            LDtkEditorGUI.DrawHelpIcon(controlRect, REFERENCE_LINK, GUI_TEXT);


            EditorGUILayout.PropertyField(_projectProp);

            GameObject obj = (GameObject)_projectProp.objectReferenceValue;

            if (TryInvalidPass(obj))
            {
                return;
            }

            string pathToObject = AssetDatabase.GetAssetPath(obj);

            _pathDrawer = new PathDrawer(_exportPathProp, content, pathToObject, "The path to export the prefab and related assets to.");
            string exportPath = _pathDrawer.DrawFolderField();

            if (!AssetDatabase.IsValidFolder(exportPath))
            {
                EditorGUILayout.LabelField("Specify a folder path inside of the unity project. (Starting from Assets)");
                EditorGUILayout.LabelField("Leave empty to export relative to the LDtk project's directory");
                return;
            }

            if (!GUILayout.Button("Export"))
            {
                return;
            }
            exportPath += $"/{obj.name}_Export";

            //first, reimport the LDtk project in case it was broken
            AssetDatabase.ImportAsset(pathToObject);

            //first try creating dupe assets
            LDtkProjectImporter assetImporter  = (LDtkProjectImporter)AssetImporter.GetAtPath(pathToObject);
            LDtkArtifactAssets  artifactAssets = AssetDatabase.LoadAssetAtPath <LDtkArtifactAssets>(pathToObject);

            _clonedAssets = new LDtkNativePrefabAssets(assetImporter, artifactAssets, exportPath);
            _clonedAssets.GenerateAssets();

            CreateNativePrefab(obj, exportPath);
        }
Exemple #2
0
 public LDtkNativePrefabFactory(LDtkNativePrefabAssets assets)
 {
     _assets = assets;
 }