Exemplo n.º 1
0
    private void LoadTextures()
    {
        System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
        stopWatch.Reset();

        stopWatch.Start();

        Unity.Collections.NativeArray <byte> data = new Unity.Collections.NativeArray <byte>(System.IO.File.ReadAllBytes($"Texture_PNG.png"), Unity.Collections.Allocator.Temp);

        PNGTexture = new Texture2D(912, 513, TextureFormat.ARGB32, true);
        PNGTexture.LoadImage(data.ToArray());
        PNGTexture.Apply();



        data.Dispose();

        stopWatch.Stop();
        Debug.Log($"<color=red>Time taken for PNG :</color> {stopWatch.ElapsedMilliseconds} ms");

        stopWatch.Reset();
        stopWatch.Start();

        DDSTexture = TextureUtils.LoadTexture_DDS(System.IO.File.ReadAllBytes($"Texture_DDS.DDS"), TextureFormat.DXT5);
        stopWatch.Stop();
        Debug.Log($"<color=red>Time taken for DDS :</color> {stopWatch.ElapsedMilliseconds} ms");
    }
Exemplo n.º 2
0
    /// <summary>
    /// Creates a visualization of the current depth image.
    /// </summary>
    /// <param name="texture">The texture to which the visualization is rendered (must be DepthWidth by DepthHeight).</param>
    public void VisualizeDepth(Texture2D texture)
    {
        if (texture.width != CameraModule.DepthWidth || texture.height != CameraModule.DepthHeight)
        {
            throw new Exception("Texture dimensions must match depth image dimensions.");
        }

        Unity.Collections.NativeArray <Color32> rawData = texture.GetRawTextureData <Color32>();

        for (int i = 0; i < rawData.Length; i++)
        {
            rawData[i] = Hud.SensorBackgroundColor;
        }

        for (int r = 0; r < CameraModule.DepthHeight; r++)
        {
            for (int c = 0; c < CameraModule.DepthWidth; c++)
            {
                if (this.DepthImage[r][c] != CameraModule.minCode && this.DepthImage[r][c] != CameraModule.maxCode)
                {
                    rawData[(CameraModule.DepthHeight - r) * texture.width + c] = CameraModule.InterpolateDepthColor(DepthImage[r][c]);
                }
            }
        }

        texture.Apply();
    }
Exemplo n.º 3
0
    /// <summary>
    /// Creates a visualization of the current LIDAR samples.
    /// </summary>
    /// <param name="texture">The texture to which the LIDAR visualization is rendered.</param>
    public void VisualizeLidar(Texture2D texture)
    {
        Unity.Collections.NativeArray <Color32> rawData = texture.GetRawTextureData <Color32>();

        // Create background: gray for in range and black for out of range
        int circleBoundary = Math.Min(texture.width, texture.height) * Math.Min(texture.width, texture.height) / 4;

        for (int r = 0; r < texture.height; r++)
        {
            for (int c = 0; c < texture.width; c++)
            {
                float x = r - texture.height / 2;
                float y = c - texture.width / 2;
                rawData[r * texture.width + c] = x * x + y * y < circleBoundary ? Hud.SensorBackgroundColor : Color.black;
            }
        }

        // Render each sample as a red pixel
        Vector2 center = new Vector2(texture.width / 2, texture.height / 2);
        float   length = Mathf.Min(texture.width / 2.0f, texture.height / 2.0f);

        for (int i = 0; i < this.Samples.Length; i++)
        {
            if (this.Samples[i] != Lidar.minCode && this.Samples[i] != Lidar.maxCode && this.Samples[i] < Lidar.visualizationRange * 10)
            {
                float   angle = 2 * Mathf.PI * i / Lidar.NumSamples;
                Vector2 point = center + this.Samples[i] / 10 / Lidar.visualizationRange * length * new Vector2(Mathf.Sin(angle), Mathf.Cos(angle));
                rawData[(int)point.y * texture.width + (int)point.x] = Color.red;
            }
        }

        texture.Apply();
    }
Exemplo n.º 4
0
    void Start()
    {
        AsciiArt_Init();
        _gid = 0;

        AsciiArt_PerlinNoise_SetNoiseSeed(_gid, 123);

        _perlinNoiseCommand          = new CommandBuffer();
        _perlinNoiseTexture          = new Texture2D(perlinNoiseWidth, perlinNoiseHeight, TextureFormat.RGBA32, false);
        _perlinNoiseTexture.wrapMode = TextureWrapMode.Clamp;

        // initialize chars image
        Texture2D _chars = Resources.Load <Texture2D>(charsResName);

        _pixelsArray = _chars.GetRawTextureData <Color32>();
        _charsPixels = _pixelsArray.ToArray();
        Debug.Log(String.Format("_pixelsArray = {0} bytes", _pixelsArray.Length));

        _charsHandle = GCHandle.Alloc(_charsPixels, GCHandleType.Pinned);
        IntPtr ptr = _charsHandle.AddrOfPinnedObject();

        Debug.Log(String.Format("CharsImage: {0}x{1}, charWidth={2}", _chars.width, _chars.height, charWidth));
        AsciiArt_Digit_SetCharsImage(_gid, ptr, _chars.width, _chars.height, charWidth);

        _digitCommand          = new CommandBuffer();
        _digitTexture          = new Texture2D(perlinNoiseWidth * charWidth, perlinNoiseHeight * _chars.height, TextureFormat.RGBA32, false);
        _digitTexture.wrapMode = TextureWrapMode.Clamp;

        var prop = new MaterialPropertyBlock();

        prop.SetTexture("_MainTex", _perlinNoiseTexture);
        prop.SetTexture("_DigitTex", _digitTexture);

        GetComponent <Renderer>().SetPropertyBlock(prop);
    }
Exemplo n.º 5
0
    void Update()
    {
        while (_requests.Count > 0)
        {
            var req = _requests.Peek();

            if (req.hasError)
            {
                Debug.Log("GPU readback error detected.");
                _requests.Dequeue();
            }
            else if (req.done)
            {
                Unity.Collections.NativeArray <Color32> buffer = req.GetData <Color32>();
                _tex.LoadRawTextureData(buffer);
                _tex.Apply();
                image.texture = _tex;
                _requests.Dequeue();
            }
            else
            {
                break;
            }
        }
    }
Exemplo n.º 6
0
    public static Mesh Copy(this Mesh mesh)
    {
        var copy = new Mesh();

        copy.uv          = new List <Vector2>(mesh.uv).ToArray();
        copy.uv2         = new List <Vector2>(mesh.uv2).ToArray();
        copy.uv3         = new List <Vector2>(mesh.uv3).ToArray();
        copy.uv4         = new List <Vector2>(mesh.uv4).ToArray();
        copy.uv5         = new List <Vector2>(mesh.uv5).ToArray();
        copy.uv6         = new List <Vector2>(mesh.uv6).ToArray();
        copy.uv7         = new List <Vector2>(mesh.uv7).ToArray();
        copy.uv8         = new List <Vector2>(mesh.uv8).ToArray();
        copy.bindposes   = new List <Matrix4x4>(mesh.bindposes).ToArray();
        copy.indexFormat = mesh.indexFormat;
        copy.bounds      = new Bounds(mesh.bounds.center, mesh.bounds.size);
        copy.vertices    = new List <Vector3>(mesh.vertices).ToArray();
        copy.normals     = new List <Vector3>(mesh.normals).ToArray();
        copy.tangents    = new List <Vector4>(mesh.tangents).ToArray();
        copy.colors      = new List <Color>(mesh.colors).ToArray();
        copy.colors32    = new List <Color32>(mesh.colors32).ToArray();
        copy.triangles   = new List <int>(mesh.triangles).ToArray();
        copy.boneWeights = new List <BoneWeight>(mesh.boneWeights).ToArray();
        Unity.Collections.NativeArray <BoneWeight1> weights        = new Unity.Collections.NativeArray <BoneWeight1>(mesh.GetAllBoneWeights(), Unity.Collections.Allocator.Temp);
        Unity.Collections.NativeArray <byte>        bonesPerVertex = new Unity.Collections.NativeArray <byte>(mesh.GetBonesPerVertex(), Unity.Collections.Allocator.Temp);
        copy.SetBoneWeights(bonesPerVertex, weights);
        copy.name      = new string(mesh.name.ToCharArray());
        copy.hideFlags = mesh.hideFlags;
        return(copy);
    }
Exemplo n.º 7
0
    public static void CreatEntity4()
    {
        //method3
        //CreateEntity(EntityArchetype, Int32, Allocator), 通过原型创建
        var a3 = w.EntityManager.CreateArchetype(typeof(Transform), typeof(EmptyData));

        Unity.Collections.NativeArray <Entity> e3_array = w.EntityManager.CreateEntity(a3, 10, Unity.Collections.Allocator.Temp);
        e3_array.Dispose();
    }
Exemplo n.º 8
0
    public static void CreatEntity5()
    {
        //method4
        var a4 = w.EntityManager.CreateArchetype(typeof(Transform));

        Unity.Collections.NativeArray <Entity> e4_array = new Unity.Collections.NativeArray <Entity>(10, Unity.Collections.Allocator.Temp);
        w.EntityManager.CreateEntity(a4, e4_array);
        e4_array.Dispose();
    }
Exemplo n.º 9
0
    private void onUpdate()
    {
        if (_request.done && _requesting)
        {
            _requesting = false;

            Unity.Collections.NativeArray <Color32> buffer = _request.GetData <Color32>();
            if (buffer != null && buffer.Length > 0)
            {
                callBack(buffer[0]);
            }
        }
    }
    static int InstanceIDToObjectList(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 2);
            Unity.Collections.NativeArray <int> arg0 = StackTraits <Unity.Collections.NativeArray <int> > .Check(L, 1);

            System.Collections.Generic.List <UnityEngine.Object> arg1 = (System.Collections.Generic.List <UnityEngine.Object>)ToLua.CheckObject(L, 2, typeof(System.Collections.Generic.List <UnityEngine.Object>));
            UnityEngine.Resources.InstanceIDToObjectList(arg0, arg1);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 11
0
    void AddCube(int amount)
    {
        Unity.Collections.NativeArray <Unity.Entities.Entity> entities = new Unity.Collections.NativeArray <Unity.Entities.Entity>(amount, Unity.Collections.Allocator.Temp);
        manager.Instantiate(GameObjectEntity, entities);
        for (int i = 0; i < amount; i++)
        {
            manager.SetComponentData(entities[i], new Unity.Transforms.Position {
                Value = new Unity.Mathematics.float3(Random.Range(1, 400), 0, Random.Range(1, 400))
            });

            manager.SetComponentData(entities[i], new Speed {
                Value = 10f
            });
        }
        entities.Dispose();
    }
Exemplo n.º 12
0
    public static Texture2D GenerateNewTexture2D()
    {
        var mainTex = new Texture2D(32, 32, TextureFormat.ARGB32, false);

        mainTex.filterMode          = FilterMode.Point;
        mainTex.alphaIsTransparency = true;
        Unity.Collections.NativeArray <Color32> data = mainTex.GetRawTextureData <Color32>();
        for (int xy = 0; xy < data.Length; xy++)
        {
            data[xy] = new Color32(30, 30, 30, 255);
            //data[xy] = new Color(0.15f, 0.15f, 0.15f, 1f);
        }

        mainTex.Apply();
        return(mainTex);
    }
Exemplo n.º 13
0
    public static void DeHighlight()
    {
        if (HighlightEnabled)
        {
            if (instance.spriteRenderer == null)
            {
                instance.spriteRenderer = Instantiate(instance.prefabSpriteRenderer);
            }

            Texture2D mainTex = instance.spriteRenderer.sprite.texture;
            Unity.Collections.NativeArray <Color32> data = mainTex.GetRawTextureData <Color32>();
            for (int xy = 0; xy < data.Length; xy++)
            {
                data[xy] = new Color32(0, 0, 0, 0);
            }
            mainTex.Apply();
        }
    }
Exemplo n.º 14
0
    // 初期化処理など
    void Start()
    {
        // ターゲットのFPSを指定します
        Application.targetFrameRate = targetFps;
        Screen.sleepTimeout         = SleepTimeout.NeverSleep;
        if (isLowResolution)
        {
            Screen.SetResolution(Screen.width / 4, Screen.height / 4, true);
        }
        // デフォルト挙動セット
        this.executeMethod = this.defaultMode;
        Resources.FindObjectsOfTypeAll <UnityEngine.UI.Dropdown>()[0].value = (int)this.defaultMode;
        // ログファイル名指定
        BatteryLogger.Instance.LogFile = this.logFileName;

        // 操作対象のtransformの作成を行います
        transformArray = new Transform[objectNum];
        for (int i = 0; i < objectNum; ++i)
        {
            GameObject gmo = Object.Instantiate <GameObject>(prefab);
            transformArray[i] = gmo.transform;
        }


        // TransformJobの為に、TransformAccessArrayを事前に生成しておきます
        #region TRANSFORM_JOB
        transformAccessArray = new UnityEngine.Jobs.TransformAccessArray(objectNum, 0);
        for (int i = 0; i < objectNum; ++i)
        {
            transformAccessArray.Add(transformArray[i]);
        }
        #endregion TRANSFORM_JOB

        // 座標計算等を並行処理させるために、事前に計算用のワークを確保しておきます
        #region ARRAY_JOB
        myStructNativeArray = new Unity.Collections.NativeArray <MyStruct>(objectNum, Unity.Collections.Allocator.Persistent);
        #endregion ARRAY_JOB
    }
    protected void LateUpdate()
    {
        bool needSendCommand = false;

        if (m_AsyncGPUReadbackRequest.done)
        {
            if (!m_AsyncGPUReadbackRequest.hasError)
            {
                Unity.Collections.NativeArray <RoleResult> resultBuffers = m_AsyncGPUReadbackRequest.GetData <RoleResult>();
                resultBuffers.CopyTo(m_RoleResults);
                for (int iResult = 0; iResult < m_RoleResults.Length; ++iResult)
                {
                    if (m_RoleResults[iResult].IsArrival == INT_TRUE)
                    {
                        m_RoleCommands[iResult].MoveTo = RandPositionOnGround();
                        needSendCommand = true;
                    }
                }
            }
            else
            {
                Debug.LogError("AsyncGPUReadback Error");
            }
            m_AsyncGPUReadbackRequest = UnityEngine.Rendering.AsyncGPUReadback.Request(m_CB_RoleResult);
        }

        if (needSendCommand)
        {
            m_CB_RoleCommand.SetData(m_RoleCommands);
        }
        MovementComputeShader.SetFloat(SHADER_PROPERTYID_DELTATIME, Time.deltaTime);

        MovementComputeShader.Dispatch(m_CS_UpdateKernel, RoleCount, 1, 1);

        Draw(MainCamera);
    }
Exemplo n.º 16
0
    IEnumerator Render()
    {
        while (true)
        {
            yield return(new WaitForEndOfFrame());

            if (sora != null)
            {
                sora.OnRender();
            }
            if (sora != null && !Recvonly)
            {
                var samples = AudioRenderer.GetSampleCountForCaptureFrame();
                if (AudioSettings.speakerMode == AudioSpeakerMode.Stereo)
                {
                    using (var buf = new Unity.Collections.NativeArray <float>(samples * 2, Unity.Collections.Allocator.Temp))
                    {
                        AudioRenderer.Render(buf);
                        sora.ProcessAudio(buf.ToArray(), 0, samples);
                    }
                }
            }
        }
    }
Exemplo n.º 17
0
 public static void Instantiate2()
 {
     e2_array_with_ins = new Unity.Collections.NativeArray <Entity>(10, Unity.Collections.Allocator.Temp);
     w.EntityManager.Instantiate(e2_origin, e2_array_with_ins);
 }
Exemplo n.º 18
0
        public NativeArray(NativeArray <T> array, Allocator allocator)
        {
            NativeArray <T> .Allocate(array.Length, allocator, out this);

            this.CopyFrom(array);
        }
Exemplo n.º 19
0
 public void CopyFrom(NativeArray <T> array)
 {
     array.CopyTo(this);
 }
Exemplo n.º 20
0
    void ConfigureLights()
    {
        mainLightExists    = false;
        shadowMapTileCount = 0;
        for (int i = 0; i < cullingResults.visibleLights.Length; i++)
        {
            if (i == maxVisibleLights)
            {
                break;
            }
            VisibleLight light = cullingResults.visibleLights[i];
            visibleLightColors[i] = light.finalColor;
            Vector4 attenuation = Vector4.zero;
            attenuation.w = 1f;
            Vector4 shadow = Vector4.zero;

            if (light.lightType == LightType.Directional)
            {
                Vector4 v = CalculateLightDir(light);
                visibleLightDirectionsOrPositions[i] = v;
                shadow   = ConfigureShadows(i, light.light);
                shadow.z = 1f;
                if (i == 0 && shadow.x > 0f && shadowCascades > 0)
                {
                    mainLightExists     = true;
                    shadowMapTileCount -= 1;
                }
            }
            else
            {
                visibleLightDirectionsOrPositions[i] =
                    light.localToWorldMatrix.GetColumn(3);
                attenuation = CalcualteAtten(light);

                if (light.lightType == LightType.Spot)
                {
                    Vector4 v = CalculateLightDir(light);
                    visibleLightSpotDirections[i] = v;
                    attenuation = CalcualteAtten(light);
                    shadow      = ConfigureShadows(i, light.light);
                    shadow.z    = 0;
                }
            }

            visibleLightAttenuations[i] = attenuation;
            shadowData[i] = shadow;
        }

        if (mainLightExists || cullingResults.visibleLights.Length > maxVisibleLights)
        {
            Unity.Collections.NativeArray <int> lightIndices = cullingResults.GetLightIndexMap(Unity.Collections.Allocator.Temp);

            if (mainLightExists)
            {
                lightIndices[0] = -1;
            }

            for (int i = maxVisibleLights; i < cullingResults.visibleLights.Length; i++)
            {
                lightIndices[i] = -1;
            }
            cullingResults.SetLightIndexMap(lightIndices);
        }
    }
Exemplo n.º 21
0
 public bool Equals(NativeArray <T> other)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 22
0
 public static JobHandle ScheduleConstruct(out NativeStream stream, NativeArray <int> lengthFromIndex0, JobHandle dependency)
 {
     return(ScheduleConstruct(out stream, lengthFromIndex0, dependency, Allocator.TempJob));
 }
Exemplo n.º 23
0
 public static bool Contains <T, U>(this NativeArray <T> array, U value) where T : struct, IEquatable <U>
 {
     return(IndexOf <T, U>(array.GetUnsafeReadOnlyPtr(), array.Length, value) != -1);
 }
            public void Execute()
            {
                var bestCost = new Unity.Collections.NativeArray <int>(this.arr.Length, Unity.Collections.Allocator.Temp);

                for (int i = 0; i < this.arr.Length; ++i)
                {
                    bestCost[i] = int.MaxValue;
                }

                bestCost[this.endNodeIndex] = 0;

                // Creating cost field
                //var visited = new Unity.Collections.NativeList<int>(this.arr.Length, Unity.Collections.Allocator.Temp);
                this.queue.Enqueue(this.endNodeIndex);
                while (this.queue.Count > 0)
                {
                    ++this.results[0];
                    var curNodeIndex = this.queue.Dequeue();
                    //visited.Add(curNodeIndex);
                    var nodeData = this.arr[curNodeIndex];
                    // TODO: add custom connections support
                    var connections = nodeData.connections;
                    for (int i = 0; i < connections.Length; ++i)
                    {
                        var conn = connections.Get(i);
                        if (conn.index < 0)
                        {
                            continue;
                        }

                        var neighbor = this.arr[conn.index];
                        if (neighbor.IsSuitable(this.constraint, this.arr, this.graphSize, this.graphCenter) == false)
                        {
                            continue;
                        }

                        if (this.pathCustomWalkableField.IsTraversable(conn.index, this.constraint) == false)
                        {
                            continue;
                        }

                        int customCost = 0;
                        if (this.pathCustomWalkableField.IsWalkable(conn.index, this.constraint) == false)
                        {
                            customCost = this.pathCustomWalkableField.GetCustomCost(conn.index, this.constraint);
                        }

                        var cost        = neighbor.penalty + customCost;
                        var endNodeCost = cost + bestCost[nodeData.index];
                        if (endNodeCost < bestCost[neighbor.index])
                        {
                            bestCost[neighbor.index] = endNodeCost;
                            this.queue.Enqueue(neighbor.index);
                        }
                    }
                }

                // Creating direction field
                for (int i = 0, cnt = this.arr.Length; i < cnt; ++i)
                {
                    var nodeIdx = this.arr[i].index;
                    var ffCost  = bestCost[nodeIdx];
                    var node    = this.arr[nodeIdx];
                    var minCost = ffCost;
                    if (this.endNodeIndex == node.index)
                    {
                        minCost = 0;
                    }

                    // TODO: add custom connections support
                    var connections = node.connections;
                    var dir         = 0;
                    var iterDir     = 2;
                    for (int j = 2; j < 10; ++j)
                    {
                        ++iterDir;

                        var conn = connections.Get(j);
                        if (conn.index < 0)
                        {
                            continue;
                        }

                        var cost = bestCost[conn.index];
                        if (cost < minCost)
                        {
                            minCost = cost;
                            dir     = iterDir - 1;
                        }
                    }

                    this.flowField[nodeIdx] = (byte)dir;
                }

                bestCost.Dispose();
            }
Exemplo n.º 25
0
    //Instantiate(NativeArray<Entity>, NativeArray<Entity>)
    public static void Instantiate4()
    {
        var e2_array_tmp = new Unity.Collections.NativeArray <Entity>(10, Unity.Collections.Allocator.Temp);

        w.EntityManager.Instantiate(e2_array_with_ins, e2_array_tmp);
    }
Exemplo n.º 26
0
    private void Update()
    {
        var sw = new System.Diagnostics.Stopwatch();

        sw.Start();

        int writeIndex = Time.frameCount % _numRTs;

        GetComponent <Camera>().targetTexture = _rt[writeIndex];

        if (_useAsync)
        {
            //_requests.Enqueue(AsyncGPUReadback.Request(_rt[readIndex], 0));

            // clear out any errors
            int maxRemoves = 8;
            for (int i = 0; i < maxRemoves && _requests.Count > 0; i++)
            {
                var request = _requests.Peek();
                if (request.hasError)
                {
                    ++_errorCount;
                    _requests.Dequeue();
                }
                else
                {
                    break;
                }
            }

            Unity.Collections.NativeArray <ushort>?data = null;

            if (_requests.Count > 0)
            {
                var request = _requests.Peek();

                if (request.done)
                {
                    ++_successCount;
                    data = request.GetData <ushort>();
                    _requests.Dequeue();
                }
            }

            if (data.HasValue)
            {
                var x = 250f; var z = 250f;
                //var pix = _tex[readIndex].GetPixelBilinear(x / 500f, z / 500f);
                int centerIdx = _rt[0].width * _rt[0].height / 2 + _rt[0].width / 2;
                //_lastSample = data.Value[centerIdx];
                //_lastSample = data.Value[Random.Range(0, data.Value.Length)];
                _lastSample[0]             = Mathf.HalfToFloat(data.Value[centerIdx * 4 + 0]);
                _lastSample[1]             = Mathf.HalfToFloat(data.Value[centerIdx * 4 + 1]);
                _lastSample[2]             = Mathf.HalfToFloat(data.Value[centerIdx * 4 + 2]);
                _marker.transform.position = new Vector3(x + _lastSample.r, _lastSample.g, z + _lastSample.b);
            }
        }
        else
        {
            int readIndex = (Time.frameCount - _readFramesBehind) % _numRTs;

            if (_readPixels)
            {
                var oldRT = RenderTexture.active;
                RenderTexture.active = _rt[readIndex];
                _tex[readIndex].ReadPixels(new Rect(0, 0, _rt[readIndex].width, _rt[readIndex].height), 0, 0, false);
                RenderTexture.active = oldRT;
            }

            if (_samplePixel)
            {
                var x = 250f; var z = 250f;
                _lastSample = _tex[readIndex].GetPixelBilinear(x / 500f, z / 500f);
                _marker.transform.position = new Vector3(x + _lastSample.r, _lastSample.g, z + _lastSample.b);
            }
        }

        timeTaken = sw.ElapsedMilliseconds;

        if (_throttleFramerate)
        {
            while (sw.ElapsedMilliseconds < 30)
            {
            }
        }
    }
Exemplo n.º 27
0
 public Enumerator(ref NativeArray <T> array)
 {
     this.m_Array = array;
     this.m_Index = -1;
 }
Exemplo n.º 28
0
 /// <summary>
 /// NativeKeyValueArrays constructor.
 /// </summary>
 /// <param name="length">The length of the arrays.</param>
 /// <param name="allocator">A member of the
 /// [Unity.Collections.Allocator](https://docs.unity3d.com/ScriptReference/Unity.Collections.Allocator.html) enumeration.</param>
 /// <param name="options">Memory should be cleared on allocation or left uninitialized.</param>
 public NativeKeyValueArrays(int length, Allocator allocator, NativeArrayOptions options)
 {
     Keys   = new NativeArray <TKey>(length, allocator, options);
     Values = new NativeArray <TValue>(length, allocator, options);
 }
    static int SetParticles(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <UnityEngine.ParticleSystem.Particle[]>(L, 2))
            {
                UnityEngine.ParticleSystem            obj  = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                UnityEngine.ParticleSystem.Particle[] arg0 = ToLua.ToStructArray <UnityEngine.ParticleSystem.Particle>(L, 2);
                obj.SetParticles(arg0);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes <Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle> >(L, 2))
            {
                UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle> arg0 = StackTraits <Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle> > .To(L, 2);

                obj.SetParticles(arg0);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes <UnityEngine.ParticleSystem.Particle[], int>(L, 2))
            {
                UnityEngine.ParticleSystem            obj  = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                UnityEngine.ParticleSystem.Particle[] arg0 = ToLua.ToStructArray <UnityEngine.ParticleSystem.Particle>(L, 2);
                int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                obj.SetParticles(arg0, arg1);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes <Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle>, int>(L, 2))
            {
                UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle> arg0 = StackTraits <Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle> > .To(L, 2);

                int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                obj.SetParticles(arg0, arg1);
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes <UnityEngine.ParticleSystem.Particle[], int, int>(L, 2))
            {
                UnityEngine.ParticleSystem            obj  = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                UnityEngine.ParticleSystem.Particle[] arg0 = ToLua.ToStructArray <UnityEngine.ParticleSystem.Particle>(L, 2);
                int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                int arg2 = (int)LuaDLL.lua_tonumber(L, 4);
                obj.SetParticles(arg0, arg1, arg2);
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes <Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle>, int, int>(L, 2))
            {
                UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem));
                Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle> arg0 = StackTraits <Unity.Collections.NativeArray <UnityEngine.ParticleSystem.Particle> > .To(L, 2);

                int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                int arg2 = (int)LuaDLL.lua_tonumber(L, 4);
                obj.SetParticles(arg0, arg1, arg2);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.ParticleSystem.SetParticles"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 30
0
 /// <summary>
 /// Adds the elements of a NativeArray to this list.
 /// </summary>
 /// <param name="elements">The items to add.</param>
 public void AddRange(NativeArray <T> elements)
 {
     AddRange(elements.GetUnsafeReadOnlyPtr(), elements.Length);
 }