Created
July 11, 2019 18:16
-
-
Save baobao/4708cabb73b5f1d90b3b40083580d0ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using Unity.Entities; | |
| [Serializable] | |
| public struct MyData : IComponentData | |
| { | |
| public float hoge; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Unity.Entities; | |
| using UnityEngine; | |
| [RequiresEntityConversion] | |
| public class MyEntity:MonoBehaviour, IConvertGameObjectToEntity | |
| { | |
| public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) | |
| { | |
| var data = new MyData() {hoge = 2f}; | |
| dstManager.AddComponentData(entity, data); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Unity.Entities; | |
| using Unity.Mathematics; | |
| using Unity.Transforms; | |
| using UnityEngine; | |
| public class MySystem : ComponentSystem | |
| { | |
| protected override void OnUpdate() | |
| { | |
| Entities.ForEach((ref MyData mydata, ref Rotation rotation)=> | |
| { | |
| var deltaTime = Time.frameCount; | |
| rotation.Value = Quaternion.Euler(deltaTime*mydata.hoge, 0, 0); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment