Search Unity

Feedback [Feature Request] Read and write from type index (I am a big boy, I can handle the responsibility)

Discussion in 'Entity Component System' started by Guedez, Oct 18, 2020.

  1. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    The methods:
    Chunk.GetDataArrayReinterpret<T>(int typeindex, int expected_size)

    EntityManager.SetIComponentDataReinterpret<T>(Entity e, int typeindex, int expected_size, T value)

    EntityManager.AddIComponentDataReinterpret<T>(Entity e, int typeindex, int expected_size, T value)

    EntityManager.GetIComponentDataReinterpret<T>(Entity e, int typeindex, int expected_size)
     
  2. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
  3. MaNaRz

    MaNaRz

    Joined:
    Aug 24, 2017
    Posts:
    117
    I would also need this. And while we are at it i'd like to have the same kind of API for DynamicBuffers too. DynamicComponentTypeHandles don't even exist for Buffers yet. This would reduce the Code for my UtilityAI massively.
     
    Guedez likes this.
  4. Zec_

    Zec_

    Joined:
    Feb 9, 2017
    Posts:
    148
    Yes please! I once played around with modifying the internal libraries to expose this kind of functionality, but I would definitely prefer if there could be some kind of exposed API for this, even if it's deemed as "unsafe access".
     
    FoodFish_ likes this.
  5. FoodFish_

    FoodFish_

    Joined:
    May 3, 2018
    Posts:
    58
    +1 for SetComponentDataRaw. Would like to set a component's value using ComponentType or TypeIndex. It would also be nice if EntityCommandBuffer.UnsafeSetComponent was exposed.
     
    Last edited: Aug 29, 2023