コード例 #1
0
    private bool TryCreateJson()
    {
        try
        {
            var json = JsonUtility.ToJson(_definitions);

            if (File.Exists(_filePath))
            {
                File.Delete(_filePath);
            }

            File.WriteAllText(_filePath, json);
            _definitions = JsonUtility.FromJson <ChunkDefinitions>(json);

            ChangeView();
        }
        catch (Exception e)
        {
            Debug.LogError(e.Message);
            return(false);
        }

        AssetDatabase.Refresh();
        return(true);
    }
    public void ReplaceChunkDefinitions(ChunkDefinitions newValue)
    {
        var index     = ConfigComponentsLookup.ChunkDefinitions;
        var component = CreateComponent <ChunkDefinitionsComponent>(index);

        component.Value = newValue;
        ReplaceComponent(index, component);
    }
    public ConfigEntity SetChunkDefinitions(ChunkDefinitions newValue)
    {
        if (hasChunkDefinitions)
        {
            throw new Entitas.EntitasException("Could not set ChunkDefinitions!\n" + this + " already has an entity with ChunkDefinitionsComponent!",
                                               "You should check if the context already has a chunkDefinitionsEntity before setting it or use context.ReplaceChunkDefinitions().");
        }
        var entity = CreateEntity();

        entity.AddChunkDefinitions(newValue);
        return(entity);
    }
    public void ReplaceChunkDefinitions(ChunkDefinitions newValue)
    {
        var entity = chunkDefinitionsEntity;

        if (entity == null)
        {
            entity = SetChunkDefinitions(newValue);
        }
        else
        {
            entity.ReplaceChunkDefinitions(newValue);
        }
    }
コード例 #5
0
    private bool TryReadJson()
    {
        try
        {
            var json = File.ReadAllText(_filePath);
            _definitions = JsonUtility.FromJson <ChunkDefinitions>(json);

            ChangeView();
        }
        catch (Exception e)
        {
            Debug.LogError(e.Message);
            return(false);
        }

        return(true);
    }