Skip to content

Instantly share code, notes, and snippets.

@tsubaki
tsubaki / ItemGetSystem.cs
Created Apr 25, 2019
Unity Physicsの使用例
View ItemGetSystem.cs
using Unity.Entities;
using Unity.Physics.Systems;
[UpdateAfter(typeof(StepPhysicsWorld))]
public class ItemGetSystem: ComponentSystem
{
private BuildPhysicsWorld buildPhysicsWorldSystem;
private StepPhysicsWorld stepPhysicsWorldSystem;
protected override void OnCreate()
View CopyTransformToGameObjectConvert.cs
using Unity.Entities;
using Unity.Transforms;
using UnityEngine;
public class CopyTransformToGameObjectConvert : MonoBehaviour, IConvertGameObjectToEntity
{
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
dstManager.AddComponentData(entity, new CopyTransformToGameObject());
}
View HitTestSystem.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Physics;
using Unity.Mathematics;
using Unity.Transforms;
using Unity.Entities;
using Unity.Physics.Systems;
[AlwaysUpdateSystem]
@tsubaki
tsubaki / Component.cs
Last active Apr 5, 2019
ISystemStateComponentData Sample
View Component.cs
using Unity.Entities;
using System;
public struct Life : IComponentData{}
[Serializable]
public struct LifeState : ISystemStateComponentData
{
public Place lastPlace;
}
@tsubaki
tsubaki / DestroyCheckSystem.cs
Created Apr 4, 2019
ISystemStateComponentDataのサンプル
View DestroyCheckSystem.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Collections;
public class DestroyCheckSystem : JobComponentSystem
{
@tsubaki
tsubaki / LoadAssetbundle.cs
Last active Mar 16, 2019
AssetBundleを復号してロードする
View LoadAssetbundle.cs
using System.Collections;
using UnityEngine;
using System.IO;
using System.Text;
public class LoadAssetbundle : MonoBehaviour
{
AssetBundle bundle;
FileStream fileStream;
@tsubaki
tsubaki / AssetBundleBuilder.cs
Created Mar 16, 2019
暗号化したAssetBundleを生成
View AssetBundleBuilder.cs
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Text;
public class AssetBundleBuilder
{
const string password = "password";
[MenuItem("Assets/Build")]
View SeekableAesStream.cs
// original : https://stackoverflow.com/a/38974483
public class SeekableAesStream : Stream
{
private Stream baseStream;
private AesManaged aes;
private ICryptoTransform encryptor;
public bool autoDisposeBaseStream { get; set; } = true;
/// <param name="salt">//** WARNING **: MUST be unique for each stream otherwise there is NO security</param>
@tsubaki
tsubaki / DistanceCheckSystem.cs
Created Mar 10, 2019
RequireForUpdateの例
View DistanceCheckSystem.cs
using UnityEngine;
using Unity.Entities;
using Unity.Transforms;
using Unity.Mathematics;
using Unity.Collections;
public class DistanceCheckSystem : ComponentSystem
{
ComponentGroup itemGroup, aiGroup;
View SwapCharacter.cs
using UnityEngine;
using UnityEngine.AddressableAssets;
public class SwapCharacter : MonoBehaviour
{
[SerializeField] Animator parentAnimator; // 登録するAnimator
private GameObject cacheCharacter; // 差し替え時に元オブジェクトを削除する用
public void Load(string characterName)
You can’t perform that action at this time.