コード例 #1
0
        private void HandleTiledAttributes(GameObject gameObject, XElement goXml)
        {
            // Add the TiledMap component
            TiledMap map = gameObject.AddComponent <TiledMap>();

            try
            {
                map.Orientation       = ImportUtils.GetAttributeAsEnum <TiledMap.MapOrientation>(goXml, "orientation");
                map.StaggerAxis       = ImportUtils.GetAttributeAsEnum <TiledMap.MapStaggerAxis>(goXml, "staggerAxis");
                map.StaggerIndex      = ImportUtils.GetAttributeAsEnum <TiledMap.MapStaggerIndex>(goXml, "staggerIndex");
                map.HexSideLength     = ImportUtils.GetAttributeAsInt(goXml, "hexSideLength");
                map.NumLayers         = ImportUtils.GetAttributeAsInt(goXml, "numLayers");
                map.NumTilesWide      = ImportUtils.GetAttributeAsInt(goXml, "numTilesWide");
                map.NumTilesHigh      = ImportUtils.GetAttributeAsInt(goXml, "numTilesHigh");
                map.TileWidth         = ImportUtils.GetAttributeAsInt(goXml, "tileWidth");
                map.TileHeight        = ImportUtils.GetAttributeAsInt(goXml, "tileHeight");
                map.ExportScale       = ImportUtils.GetAttributeAsFloat(goXml, "exportScale");
                map.MapWidthInPixels  = ImportUtils.GetAttributeAsInt(goXml, "mapWidthInPixels");
                map.MapHeightInPixels = ImportUtils.GetAttributeAsInt(goXml, "mapHeightInPixels");
            }
            catch
            {
                Debug.LogWarning(String.Format("Error adding TiledMap component. Are you using an old version of Tiled2Unity in your Unity project?"));
                GameObject.DestroyImmediate(map);
            }
        }
コード例 #2
0
        private void HandleTiledAttributes(GameObject gameObject, XElement goXml, Tiled2Unity.ImportBehaviour importComponent)
        {
            // Add the TiledMap component
            TiledMap map = gameObject.AddComponent <TiledMap>();

            try
            {
                map.Orientation       = ImportUtils.GetAttributeAsEnum <TiledMap.MapOrientation>(goXml, "orientation");
                map.StaggerAxis       = ImportUtils.GetAttributeAsEnum <TiledMap.MapStaggerAxis>(goXml, "staggerAxis");
                map.StaggerIndex      = ImportUtils.GetAttributeAsEnum <TiledMap.MapStaggerIndex>(goXml, "staggerIndex");
                map.HexSideLength     = ImportUtils.GetAttributeAsInt(goXml, "hexSideLength");
                map.NumLayers         = ImportUtils.GetAttributeAsInt(goXml, "numLayers");
                map.NumTilesWide      = ImportUtils.GetAttributeAsInt(goXml, "numTilesWide");
                map.NumTilesHigh      = ImportUtils.GetAttributeAsInt(goXml, "numTilesHigh");
                map.TileWidth         = ImportUtils.GetAttributeAsInt(goXml, "tileWidth");
                map.TileHeight        = ImportUtils.GetAttributeAsInt(goXml, "tileHeight");
                map.ExportScale       = ImportUtils.GetAttributeAsFloat(goXml, "exportScale");
                map.MapWidthInPixels  = ImportUtils.GetAttributeAsInt(goXml, "mapWidthInPixels");
                map.MapHeightInPixels = ImportUtils.GetAttributeAsInt(goXml, "mapHeightInPixels");
                map.BackgroundColor   = ImportUtils.GetAttributeAsColor(goXml, "backgroundColor", Color.black);
            }
            catch
            {
                importComponent.RecordWarning("Couldn't add TiledMap component. Are you using an old version of Tiled2Unity in your Unity project?");
                GameObject.DestroyImmediate(map);
            }
        }
コード例 #3
0
 public void HandleCustomProperties(UnityEngine.GameObject gameObject,
                                    IDictionary <string, string> props)
 {
     // Add a terrain type to our game object
     if (props.ContainsKey("terrainType"))
     {
         TerrainType terrainType = (TerrainType)ImportUtils.GetAttributeAsEnum(props["terrainType"], typeof(TerrainType));
         if (terrainType != null)
         {
             gameObject.AddComponent <TerrainTagChecker>();
             gameObject.GetComponent <TerrainTagChecker>().curTerrainType = terrainType;
         }
     }
 }