Ejemplo n.º 1
0
        internal void Init(TilesetEditor editor)
        {
            this.editor = editor;

            // Derive the default description from available XML documentation
            Type type = this.GetType();

            XmlCodeDoc.Entry docEntry = HelpSystem.GetXmlCodeDoc(type);
            if (docEntry != null)
            {
                this.xmlDocDesc = docEntry.Summary;
            }
        }
Ejemplo n.º 2
0
    protected void OnTilesetEditorButtonClicked(object sender, EventArgs e)
    {
        if (Project == null)
        {
            return;
        }
        Window        win = new Window(WindowType.Toplevel);
        TilesetEditor a   = new TilesetEditor(tilesetViewer1.Tileset);

        win.Add(a);
        win.Title = "Edit Tileset";
        win.ShowAll();
    }
Ejemplo n.º 3
0
        private bool PrepareTilset()
        {
            // use with UNITY JSON
            //this.pyxelTilemap = JsonUtility.FromJson<PyxelEditTilemap>(this.tilemapJSON.text);

            // use with JSONObject class (http://wiki.unity3d.com/index.php?title=JSONObject)
            this.pyxelTilemap = DeserializeJSON();

            string path      = AssetDatabase.GetAssetPath(pyxelEdit.tilemapJSON.GetInstanceID());
            string assetPath = System.IO.Path.GetDirectoryName(path) + "/" + pyxelEdit.tilemapJSON.name + "_tileset.asset";

            this.tileset = AssetDatabase.LoadAssetAtPath <Tileset>(assetPath);
            bool createNewTileset = !this.tileset;

            if (createNewTileset)
            {
                this.tileset = ScriptableObject.CreateInstance <Tileset>();
            }

            string pathToTexture = System.IO.Path.GetDirectoryName(path) + "/" + pyxelEdit.tilemapJSON.name + ".png";

            Texture2D tilesetTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(pathToTexture, typeof(Texture2D));

            if (tilesetTexture == null)
            {
                Debug.LogError("PyxelEdit ERROR: missing texture at " + pathToTexture + " !");
                return(false);
            }
            else
            {
                tileset.PixelsPerUnit = this.pyxelTilemap.tilewidth;
                tileset.TilePxSize    = new Vector2(this.pyxelTilemap.tilewidth, this.pyxelTilemap.tileheight);
                tileset.AtlasTexture  = tilesetTexture;
                tileset.SliceOffset   = pyxelEdit.sliceOffset;
                tileset.SlicePadding  = pyxelEdit.slicePadding;
                tileset.Slice();
                TilesetEditor.OptimizeTextureImportSettings(tileset.AtlasTexture);
                if (createNewTileset)
                {
                    AssetDatabaseUtility.CreateAssetAndDirectories(tileset, assetPath);
                }
                EditorUtility.SetDirty(this.tileset);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
                return(true);
            }
        }
 public static void SceneGUI(NetworkScriptableTileLayer layerBase)
 {
     if (layerBase.scriptableLayers == null || layerBase.scriptableLayers.Length == 0)
     {
         return;
     }
     if (selectedLayer >= layerBase.scriptableLayers.Length)
     {
         selectedLayer = 0;
     }
     Handles.BeginGUI();
     GUILayout.BeginHorizontal("box", GUILayout.Width(100));
     if (GUILayout.Button("<"))
     {
         selectedLayer--;
         if (selectedLayer < 0)
         {
             selectedLayer = layerBase.scriptableLayers.Length - 1;
         }
         if (layerBase.scriptableLayers[selectedLayer].layers.Length > 0)
         {
             TilesetEditor.ChangeTileLayer(layerBase.scriptableLayers[selectedLayer].layers[0]);
         }
     }
     GUILayout.Label(layerBase.scriptableLayers[selectedLayer].name);
     if (GUILayout.Button(">"))
     {
         selectedLayer++;
         if (selectedLayer >= layerBase.scriptableLayers.Length)
         {
             selectedLayer = 0;
         }
         if (layerBase.scriptableLayers[selectedLayer].layers.Length > 0)
         {
             TilesetEditor.ChangeTileLayer(layerBase.scriptableLayers[selectedLayer].layers[0]);
         }
     }
     GUILayout.EndHorizontal();
     Handles.EndGUI();
 }
Ejemplo n.º 5
0
        internal void Init(TilesetEditor editor)
        {
            this.editor = editor;

            // Derive the default description from available XML documentation
            Type type = this.GetType();
            XmlCodeDoc.Entry docEntry = HelpSystem.GetXmlCodeDoc(type);
            if (docEntry != null) this.xmlDocDesc = docEntry.Summary;
        }