Exemplo n.º 1
0
        static int __CreateInstance(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (LuaAPI.lua_gettop(L) == 1)
                {
                    var gen_ret = new UnityEngine.MeshCollider();
                    translator.Push(L, gen_ret);

                    return(1);
                }
            }
            catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.MeshCollider constructor!"));
        }
        static int __CreateInstance(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (LuaAPI.lua_gettop(L) == 2 && translator.Assignable <UnityEngine.MeshCollider>(L, 2))
                {
                    UnityEngine.MeshCollider _collider = (UnityEngine.MeshCollider)translator.GetObject(L, 2, typeof(UnityEngine.MeshCollider));

                    FairyGUI.MeshColliderHitTest gen_ret = new FairyGUI.MeshColliderHitTest(_collider);
                    translator.Push(L, gen_ret);

                    return(1);
                }
            }
            catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to FairyGUI.MeshColliderHitTest constructor!"));
        }
Exemplo n.º 3
0
    private ulong GetGeometryID()
    {
        ulong geometryID = AkSurfaceReflector.INVALID_GEOMETRY_ID;

        AkSurfaceReflector surfaceReflector = GetComponent <AkSurfaceReflector>();

        if (surfaceReflector && surfaceReflector.enabled)
        {
            geometryID = surfaceReflector.GetID();
        }
        else
        {
            if (roomCollider == null)
            {
                roomCollider = GetComponent <UnityEngine.Collider>();
            }

            if (roomCollider.GetType() == typeof(UnityEngine.MeshCollider))
            {
                geometryID = GetID();
                UnityEngine.MeshCollider meshCollider = GetComponent <UnityEngine.MeshCollider>();
#if UNITY_EDITOR
                if (previousColliderType == typeof(UnityEngine.MeshCollider) &&
                    previousMeshCollider != null &&
                    previousMeshCollider.sharedMesh == meshCollider.sharedMesh &&
                    previousPosition == transform.position &&
                    previousRotation == transform.rotation &&
                    previousScale == transform.localScale)
                {
                    return(geometryID);
                }
#endif
                AkSurfaceReflector.SetGeometryFromMesh(meshCollider.sharedMesh, transform, geometryID, INVALID_ROOM_ID, false, false, false);
#if UNITY_EDITOR
                previousMeshCollider = meshCollider;
                previousPosition     = transform.position;
                previousRotation     = transform.rotation;
                previousScale        = transform.localScale;
#endif
                previousColliderType = typeof(UnityEngine.MeshCollider);
            }
            else if (roomCollider.GetType() == typeof(UnityEngine.BoxCollider))
            {
                geometryID = GetID();
                UnityEngine.BoxCollider boxCollider = GetComponent <UnityEngine.BoxCollider>();
#if UNITY_EDITOR
                if (previousColliderType == typeof(UnityEngine.BoxCollider) &&
                    previousBoxCollider != null &&
                    previousPosition == roomCollider.bounds.center &&
                    previousRotation == transform.rotation &&
                    previousScale == new UnityEngine.Vector3(transform.localScale.x * boxCollider.size.x,
                                                             transform.localScale.y * boxCollider.size.y,
                                                             transform.localScale.z * boxCollider.size.z))
                {
                    return(geometryID);
                }
#endif
                UnityEngine.GameObject tempGameObject = UnityEngine.GameObject.CreatePrimitive(UnityEngine.PrimitiveType.Cube);
                UnityEngine.Mesh       mesh           = tempGameObject.GetComponent <UnityEngine.MeshFilter>().sharedMesh;

                tempGameObject.transform.position = boxCollider.bounds.center;
                tempGameObject.transform.rotation = transform.rotation;
                UnityEngine.Vector3 roomScale = new UnityEngine.Vector3();
                roomScale.x = transform.localScale.x * boxCollider.size.x;
                roomScale.y = transform.localScale.y * boxCollider.size.y;
                roomScale.z = transform.localScale.z * boxCollider.size.z;
                tempGameObject.transform.localScale = roomScale;

                AkSurfaceReflector.SetGeometryFromMesh(mesh, tempGameObject.transform, geometryID, INVALID_ROOM_ID, false, false, false);
#if UNITY_EDITOR
                previousBoxCollider = boxCollider;
                previousPosition    = tempGameObject.transform.position;
                previousRotation    = tempGameObject.transform.rotation;
                previousScale       = tempGameObject.transform.localScale;
#endif
                previousColliderType = typeof(UnityEngine.BoxCollider);
                UnityEngine.GameObject.Destroy(tempGameObject);
            }
            else if (roomCollider.GetType() == typeof(UnityEngine.CapsuleCollider))
            {
                geometryID = GetID();
                UnityEngine.CapsuleCollider capsuleCollider = GetComponent <UnityEngine.CapsuleCollider>();
#if UNITY_EDITOR
                if (previousColliderType == typeof(UnityEngine.CapsuleCollider) &&
                    previousCapsuleCollider != null &&
                    previousPosition == capsuleCollider.bounds.center &&
                    previousRotation == transform.rotation &&
                    previousScale == GetCapsuleScale(transform.localScale, capsuleCollider.radius, capsuleCollider.height, capsuleCollider.direction))
                {
                    return(geometryID);
                }
#endif
                UnityEngine.GameObject tempGameObject = UnityEngine.GameObject.CreatePrimitive(UnityEngine.PrimitiveType.Cube);
                UnityEngine.Mesh       mesh           = tempGameObject.GetComponent <UnityEngine.MeshFilter>().sharedMesh;

                tempGameObject.transform.position   = capsuleCollider.bounds.center;
                tempGameObject.transform.rotation   = transform.rotation;
                tempGameObject.transform.localScale = GetCapsuleScale(transform.localScale, capsuleCollider.radius, capsuleCollider.height, capsuleCollider.direction);

                AkSurfaceReflector.SetGeometryFromMesh(mesh, tempGameObject.transform, geometryID, INVALID_ROOM_ID, false, false, false);
#if UNITY_EDITOR
                previousCapsuleCollider = capsuleCollider;
                previousPosition        = tempGameObject.transform.position;
                previousRotation        = tempGameObject.transform.rotation;
                previousScale           = tempGameObject.transform.localScale;
#endif
                previousColliderType = typeof(UnityEngine.CapsuleCollider);
                UnityEngine.GameObject.Destroy(tempGameObject);
            }
            else if (roomCollider.GetType() == typeof(UnityEngine.SphereCollider))
            {
                geometryID = GetID();
#if UNITY_EDITOR
                if (previousColliderType == typeof(UnityEngine.SphereCollider) &&
                    previousPosition == roomCollider.bounds.center &&
                    previousScale == roomCollider.bounds.size)
                {
                    return(geometryID);
                }
#endif
                UnityEngine.GameObject tempGameObject = UnityEngine.GameObject.CreatePrimitive(UnityEngine.PrimitiveType.Sphere);
                UnityEngine.Mesh       mesh           = tempGameObject.GetComponent <UnityEngine.MeshFilter>().sharedMesh;

                tempGameObject.transform.position   = roomCollider.bounds.center;
                tempGameObject.transform.localScale = roomCollider.bounds.size;

                AkSurfaceReflector.SetGeometryFromMesh(mesh, tempGameObject.transform, geometryID, INVALID_ROOM_ID, false, false, false);
#if UNITY_EDITOR
                previousColliderType = typeof(UnityEngine.SphereCollider);
                previousPosition     = tempGameObject.transform.position;
                previousScale        = tempGameObject.transform.localScale;
#endif
                previousColliderType = typeof(UnityEngine.SphereCollider);
                UnityEngine.GameObject.Destroy(tempGameObject);
            }
            else
            {
                if (previousColliderType == roomCollider.GetType())
                {
                    return(geometryID);
                }

                UnityEngine.Debug.LogWarning(name + " has an invalid collider for wet transmission. Wet Transmission will be disabled.");
                // in case a geometry was added with the room's ID, remove it
                if (previousColliderType == typeof(UnityEngine.MeshCollider) ||
                    previousColliderType == typeof(UnityEngine.BoxCollider) ||
                    previousColliderType == typeof(UnityEngine.SphereCollider) ||
                    previousColliderType == typeof(UnityEngine.CapsuleCollider))
                {
                    AkSoundEngine.RemoveGeometry(GetID());
                }

                previousColliderType = roomCollider.GetType();
            }
        }

        return(geometryID);
    }