1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using System;
- using UnityEngine;
- using System.Runtime.InteropServices;
- using GPUECSAnimationBaker.Engine.AnimatorSystem;
- public class MyPlugin : MonoBehaviour
- {
-
-
-
-
- public Material material;
- public Mesh mesh;
- const int numInstances = 10;
- struct MyInstanceData
- {
- public Matrix4x4 objectToWorld;
- public float myOtherData;
- public uint renderingLayerMask;
- };
- // void Update()
- // {
- // RenderParams rp = new RenderParams(material);
- // MyInstanceData[] instData = new MyInstanceData[numInstances];
- // for(int i=0; i<numInstances; ++i)
- // {
- // instData[i].objectToWorld = Matrix4x4.Translate(new Vector3(-4.5f+i, 0.0f, 5.0f));
- // instData[i].renderingLayerMask = (i & 1) == 0 ? 1u : 2u;
- // }
- // Graphics.RenderMeshInstanced(rp, mesh, 0, instData);
- // }
-
- void Update()
- {
- RenderParams rp = new RenderParams(material);
- Matrix4x4[] instData = new Matrix4x4[numInstances];
- for(int i=0; i<numInstances; ++i)
- instData[i] = Matrix4x4.Translate(new Vector3(-4.5f+i, 0.0f, 5.0f));
- Graphics.RenderMeshInstanced(rp, mesh, 0, instData);
- }
-
-
-
-
-
- // public GPUAnimtion GPUAnimtion;
- //
- // public int index;
- //
- // private void Start()
- // {
- // GPUAnimtion = new GPUAnimtion();
- // GpuEcsAnimatorBehaviour gpuEcsAnimatorBehaviour= gameObject.transform.GetComponentInChildren<GpuEcsAnimatorBehaviour>();
- // GPUAnimtion.Init(gpuEcsAnimatorBehaviour);
- // }
- //
- // [ContextMenu("dsada")]
- // public void TestSet()
- // {
- // GPUAnimtion.SetAnimtionIndex(index);
- // }
- //
- // private void Update()
- // {
- // GPUAnimtion.Update();
- // // Graphics.DrawMeshInstanced();
- // }
-
- // // 声明C++函数
- // [DllImport("ThreadTool")]
- // private static extern int Add(int a, int b);
- //
- // [DllImport("ThreadTool")]
- // private static extern void CallCSharpFunction(Callback callback);
- //
- // // 定义回调委托
- // public delegate int Callback(int value);
- //
- // // C#回调函数
- // private int MyCallback(int value)
- // {
- // Debug.Log("C# received value from C++: " + value);
- // return value * 2;
- // }
- //
- // void Start()
- // {
- // // 调用C++函数
- // int result = Add(5, 3);
- // Debug.Log("Result from C++: " + result); // 输出: Result from C++: 8
- //
- // // 注册C#回调函数并调用C++函数
- // CallCSharpFunction(MyCallback);
- // }
- }
|