private void LoadMech() { // Build Mech _mech = Instantiate(MechPreferences.MechPrefab); MechBaseModel baseModel = JsonLoader.Parse <MechBaseModel>(Application.dataPath + MechPreferences.MechBaseJsonPath + BaseToLoad); _mech.Base.Model = baseModel; // Load model's asset #if UNITY_EDITOR BaseComponent asset = AssetDatabase.LoadAssetAtPath <BaseComponent>("Assets" + MechPreferences.MechBaseContentPath + baseModel.ModelAsset + ".prefab"); if (asset == null) { Debug.LogError("Unable to load asset at " + "Assets" + MechPreferences.MechBaseContentPath + baseModel.ModelAsset); return; } asset = Instantiate(asset); _mech.Base.View.AttachBaseAsset(asset); #endif // Center on board HexTile tile = _hexBoard.View.HexTiles[55]; _mech.transform.position = tile.View.Pos; _mech.View.Index = 55; }
private void Start() { _preferences = _hexBoard.Preferences; HexBoardModel hexBoardModel = JsonLoader.Parse <HexBoardModel>(Application.dataPath + _preferences.HexBoardPath + FileToLoad); _hexBoard.Model = hexBoardModel; _hexBoard.Controller.CreateBoard(); }
//---- Private //------------ private void LoadBoard() { HexBoardModel hexBoardModel = JsonLoader.Parse <HexBoardModel>(Application.dataPath + HexPreferences.HexBoardPath + BoardToLoad); if (hexBoardModel == null) { Debug.LogError("Unable to load HexBoard at " + Application.dataPath + HexPreferences.HexBoardPath + BoardToLoad); } _hexBoard.Model = hexBoardModel; _hexBoard.Controller.CreateBoard(); }
public void NoId_Throw() { var assembly = typeof(LibraTests).Assembly; var loader = new JsonLoader(_logger); loader.Register(_allTypes); var resource = assembly.GetManifestResourceNames().First(r => r.EndsWith("no_id.json")); var stream = assembly.GetManifestResourceStream(resource); Throws <ResourceSystemException>(() => loader.Parse(stream)); }
private List <Resource> LoadAll() { var assembly = typeof(LibraTests).Assembly; var loader = new JsonLoader(_logger); loader.Register(_allTypes); var result = new List <Resource>(); foreach (string res in assembly.GetManifestResourceNames()) { if (res.EndsWith(".rs")) { _logger.LogInfo($"Parsing: {res}"); var resource = loader.Parse(assembly.GetManifestResourceStream(res)); result.Add(resource); } } return(result); }