public LDtkTileArtifactFactory(LDtkProjectImporter importer, LDtkArtifactAssets assets, Texture2D srcTex, Vector2Int srcPos, int pixelsPerUnit)
 {
     _importer      = importer;
     _assets        = assets;
     _srcTex        = srcTex;
     _srcPos        = srcPos;
     _pixelsPerUnit = pixelsPerUnit;
 }
Esempio n. 2
0
        private void CreateArtifactAsset()
        {
            //the bank for storing the auto-generated items.
            _artifacts      = ScriptableObject.CreateInstance <LDtkArtifactAssets>();
            _artifacts.name = AssetName + "_Assets";

            ImportContext.AddObjectToAsset("artifacts", _artifacts, (Texture2D)LDtkIconUtility.GetUnityIcon("Tilemap"));
        }
Esempio n. 3
0
 public LDtkNativePrefabAssets(LDtkProjectImporter importer, LDtkArtifactAssets assets, string path)
 {
     _importer   = importer;
     _path       = path;
     _assets     = assets;
     _oldSprite  = LDtkResourcesLoader.LoadDefaultTileSprite();
     _newTexture = Texture2D.whiteTexture;
 }
Esempio n. 4
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);
        }