//---- Functions
    //--------------
    public override void OnInspectorGUI()
    {
        if (_preferences == null)
        {
            _preferences = target as HexTilePreferences;
        }

        base.OnInspectorGUI();
        if (_textureDictionary == null)
        {
            _textureDictionary = _preferences.Textures;
        }
        if (_materialDictionary == null)
        {
            _materialDictionary = _preferences.Materials;
        }
        DrawTextureDictionary();
        DrawMaterialDictionary();

        // Set dirty so can save out
        if (_isDirty)
        {
            _isDirty = false;
            EditorUtility.SetDirty(_preferences);
            AssetDatabase.SaveAssets();
        }
    }
Пример #2
0
    private void Start()
    {
        _preferences = _hexBoard.Preferences;
        HexBoardModel hexBoardModel = JsonLoader.Parse <HexBoardModel>(Application.dataPath + _preferences.HexBoardPath + FileToLoad);

        _hexBoard.Model = hexBoardModel;
        _hexBoard.Controller.CreateBoard();
    }
Пример #3
0
    private static void LoadPreference()
    {
        string path = "Assets/Preferences/HexTilePreferences.asset";

        _hexTilePreferences = Instantiate(AssetDatabase.LoadAssetAtPath <HexTilePreferences>(path));
        if (_hexTilePreferences == null)
        {
            Debug.LogError("Unable to load Hex Tile Preferences @" + path);
        }
    }
Пример #4
0
        //---- Public
        //-----------
        public void CreateBoard()
        {
            HexBoardModel      model       = HexBoard.Model;
            HexBoardView       view        = HexBoard.View;
            HexTilePreferences preferences = HexBoard.Preferences;

            view.HexTiles = new List <HexTile>(model.HexTileCount);
            for (int i = 0; i < model.HexTileCount; i++)
            {
                HexTile      hexTile      = Object.Instantiate(preferences.Prefab, view.Root);
                HexTileModel hexTileModel = model.HexTileModels[i];
                hexTile.name  = "Tile_" + i;
                hexTile.Model = hexTileModel;
                hexTile.View.SetMaterial(preferences.Materials[hexTileModel.MaterialName]);
                hexTile.View.SetTexture(preferences.Textures[hexTileModel.TextureName]);
                hexTile.transform.localPosition = hexTileModel.Position.Convert();
                hexTile.transform.localRotation = Quaternion.Euler(hexTileModel.Rotation.Convert());
                hexTile.transform.localScale    = hexTileModel.Scale.Convert();
                hexTile.View.Index = i;
                view.HexTiles.Add(hexTile);
            }
        }