Inheritance: Behaviour
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.GUILayer o;
         o = new UnityEngine.GUILayer();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int HitTest(IntPtr l)
 {
     try {
         UnityEngine.GUILayer self = (UnityEngine.GUILayer)checkSelf(l);
         UnityEngine.Vector3  a1;
         checkType(l, 2, out a1);
         var ret = self.HitTest(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 3
0
        private static void HitTestLegacyGUI(Camera camera, Vector3 mousePosition, ref SendMouseEvents.HitInfo hitInfo)
        {
            GUILayer component = camera.GetComponent <GUILayer>();

            if (component)
            {
                GUIElement gUIElement = component.HitTest(mousePosition);
                if (gUIElement)
                {
                    hitInfo.target = gUIElement.gameObject;
                    hitInfo.camera = camera;
                }
                else
                {
                    hitInfo.target = null;
                    hitInfo.camera = null;
                }
            }
        }
Ejemplo n.º 4
0
 public GUIElement HitTest(Vector3 screenPosition)
 {
     return(GUILayer.INTERNAL_CALL_HitTest(this, ref screenPosition));
 }
Ejemplo n.º 5
0
 private static extern GUIElement INTERNAL_CALL_HitTest(GUILayer self, ref Vector3 screenPosition);
Ejemplo n.º 6
0
        private static void DoSendMouseEvents(int skipRTCameras)
        {
            Vector3 mousePosition   = Input.mousePosition;
            int     allCamerasCount = Camera.allCamerasCount;

            if (SendMouseEvents.m_Cameras == null || SendMouseEvents.m_Cameras.Length != allCamerasCount)
            {
                SendMouseEvents.m_Cameras = new Camera[allCamerasCount];
            }
            Camera.GetAllCameras(SendMouseEvents.m_Cameras);
            for (int i = 0; i < SendMouseEvents.m_CurrentHit.Length; i++)
            {
                SendMouseEvents.m_CurrentHit[i] = default(SendMouseEvents.HitInfo);
            }
            if (!SendMouseEvents.s_MouseUsed)
            {
                Camera[] cameras = SendMouseEvents.m_Cameras;
                for (int j = 0; j < cameras.Length; j++)
                {
                    Camera camera = cameras[j];
                    if (!(camera == null) && (skipRTCameras == 0 || !(camera.targetTexture != null)))
                    {
                        if (camera.pixelRect.Contains(mousePosition))
                        {
                            GUILayer component = camera.GetComponent <GUILayer>();
                            if (component)
                            {
                                GUIElement gUIElement = component.HitTest(mousePosition);
                                if (gUIElement)
                                {
                                    SendMouseEvents.m_CurrentHit[0].target = gUIElement.gameObject;
                                    SendMouseEvents.m_CurrentHit[0].camera = camera;
                                }
                                else
                                {
                                    SendMouseEvents.m_CurrentHit[0].target = null;
                                    SendMouseEvents.m_CurrentHit[0].camera = null;
                                }
                            }
                            if (camera.eventMask != 0)
                            {
                                Ray        ray        = camera.ScreenPointToRay(mousePosition);
                                float      z          = ray.direction.z;
                                float      distance   = (!Mathf.Approximately(0f, z)) ? Mathf.Abs((camera.farClipPlane - camera.nearClipPlane) / z) : float.PositiveInfinity;
                                GameObject gameObject = camera.RaycastTry(ray, distance, camera.cullingMask & camera.eventMask);
                                if (gameObject != null)
                                {
                                    SendMouseEvents.m_CurrentHit[1].target = gameObject;
                                    SendMouseEvents.m_CurrentHit[1].camera = camera;
                                }
                                else if (camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.Color)
                                {
                                    SendMouseEvents.m_CurrentHit[1].target = null;
                                    SendMouseEvents.m_CurrentHit[1].camera = null;
                                }
                                GameObject gameObject2 = camera.RaycastTry2D(ray, distance, camera.cullingMask & camera.eventMask);
                                if (gameObject2 != null)
                                {
                                    SendMouseEvents.m_CurrentHit[2].target = gameObject2;
                                    SendMouseEvents.m_CurrentHit[2].camera = camera;
                                }
                                else if (camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.Color)
                                {
                                    SendMouseEvents.m_CurrentHit[2].target = null;
                                    SendMouseEvents.m_CurrentHit[2].camera = null;
                                }
                            }
                        }
                    }
                }
            }
            for (int k = 0; k < SendMouseEvents.m_CurrentHit.Length; k++)
            {
                SendMouseEvents.SendEvents(k, SendMouseEvents.m_CurrentHit[k]);
            }
            SendMouseEvents.s_MouseUsed = false;
        }
Ejemplo n.º 7
0
        private static void DoSendMouseEvents(int skipRTCameras)
        {
            Vector3 mousePosition   = Input.mousePosition;
            int     allCamerasCount = Camera.allCamerasCount;

            if (SendMouseEvents.m_Cameras == null || SendMouseEvents.m_Cameras.Length != allCamerasCount)
            {
                SendMouseEvents.m_Cameras = new Camera[allCamerasCount];
            }
            Camera.GetAllCameras(SendMouseEvents.m_Cameras);
            for (int index = 0; index < SendMouseEvents.m_CurrentHit.Length; ++index)
            {
                SendMouseEvents.m_CurrentHit[index] = new SendMouseEvents.HitInfo();
            }
            if (!SendMouseEvents.s_MouseUsed)
            {
                foreach (Camera camera in SendMouseEvents.m_Cameras)
                {
                    if (!((Object)camera == (Object)null) && (skipRTCameras == 0 || !((Object)camera.targetTexture != (Object)null)) && camera.pixelRect.Contains(mousePosition))
                    {
                        GUILayer component = camera.GetComponent <GUILayer>();
                        if ((bool)((Object)component))
                        {
                            GUIElement guiElement = component.HitTest(mousePosition);
                            if ((bool)((Object)guiElement))
                            {
                                SendMouseEvents.m_CurrentHit[0].target = guiElement.gameObject;
                                SendMouseEvents.m_CurrentHit[0].camera = camera;
                            }
                            else
                            {
                                SendMouseEvents.m_CurrentHit[0].target = (GameObject)null;
                                SendMouseEvents.m_CurrentHit[0].camera = (Camera)null;
                            }
                        }
                        if (camera.eventMask != 0)
                        {
                            Ray        ray         = camera.ScreenPointToRay(mousePosition);
                            float      z           = ray.direction.z;
                            float      distance    = !Mathf.Approximately(0.0f, z) ? Mathf.Abs((camera.farClipPlane - camera.nearClipPlane) / z) : float.PositiveInfinity;
                            GameObject gameObject1 = camera.RaycastTry(ray, distance, camera.cullingMask & camera.eventMask);
                            if ((Object)gameObject1 != (Object)null)
                            {
                                SendMouseEvents.m_CurrentHit[1].target = gameObject1;
                                SendMouseEvents.m_CurrentHit[1].camera = camera;
                            }
                            else if (camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.Color)
                            {
                                SendMouseEvents.m_CurrentHit[1].target = (GameObject)null;
                                SendMouseEvents.m_CurrentHit[1].camera = (Camera)null;
                            }
                            GameObject gameObject2 = camera.RaycastTry2D(ray, distance, camera.cullingMask & camera.eventMask);
                            if ((Object)gameObject2 != (Object)null)
                            {
                                SendMouseEvents.m_CurrentHit[2].target = gameObject2;
                                SendMouseEvents.m_CurrentHit[2].camera = camera;
                            }
                            else if (camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.Color)
                            {
                                SendMouseEvents.m_CurrentHit[2].target = (GameObject)null;
                                SendMouseEvents.m_CurrentHit[2].camera = (Camera)null;
                            }
                        }
                    }
                }
            }
            for (int i = 0; i < SendMouseEvents.m_CurrentHit.Length; ++i)
            {
                SendMouseEvents.SendEvents(i, SendMouseEvents.m_CurrentHit[i]);
            }
            SendMouseEvents.s_MouseUsed = false;
        }
Ejemplo n.º 8
0
 private static extern GUIElement INTERNAL_CALL_HitTest(GUILayer self, ref Vector3 screenPosition);
Ejemplo n.º 9
0
        private static void DoSendMouseEvents(int skipRTCameras)
        {
            Vector3 mousePosition   = Input.mousePosition;
            int     allCamerasCount = Camera.allCamerasCount;

            if ((m_Cameras == null) || (m_Cameras.Length != allCamerasCount))
            {
                m_Cameras = new Camera[allCamerasCount];
            }
            Camera.GetAllCameras(m_Cameras);
            for (int i = 0; i < m_CurrentHit.Length; i++)
            {
                m_CurrentHit[i] = new HitInfo();
            }
            if (!s_MouseUsed)
            {
                foreach (Camera camera in m_Cameras)
                {
                    if (((camera != null) && ((skipRTCameras == 0) || (camera.targetTexture == null))) && camera.pixelRect.Contains(mousePosition))
                    {
                        GUILayer component = camera.GetComponent <GUILayer>();
                        if (component != null)
                        {
                            GUIElement element = component.HitTest(mousePosition);
                            if (element != null)
                            {
                                m_CurrentHit[0].target = element.gameObject;
                                m_CurrentHit[0].camera = camera;
                            }
                            else
                            {
                                m_CurrentHit[0].target = null;
                                m_CurrentHit[0].camera = null;
                            }
                        }
                        if (camera.eventMask != 0)
                        {
                            Ray        ray      = camera.ScreenPointToRay(mousePosition);
                            float      z        = ray.direction.z;
                            float      distance = !Mathf.Approximately(0f, z) ? Mathf.Abs((float)((camera.farClipPlane - camera.nearClipPlane) / z)) : float.PositiveInfinity;
                            GameObject obj2     = camera.RaycastTry(ray, distance, camera.cullingMask & camera.eventMask);
                            if (obj2 != null)
                            {
                                m_CurrentHit[1].target = obj2;
                                m_CurrentHit[1].camera = camera;
                            }
                            else if ((camera.clearFlags == CameraClearFlags.Skybox) || (camera.clearFlags == CameraClearFlags.Color))
                            {
                                m_CurrentHit[1].target = null;
                                m_CurrentHit[1].camera = null;
                            }
                            GameObject obj3 = camera.RaycastTry2D(ray, distance, camera.cullingMask & camera.eventMask);
                            if (obj3 != null)
                            {
                                m_CurrentHit[2].target = obj3;
                                m_CurrentHit[2].camera = camera;
                            }
                            else if ((camera.clearFlags == CameraClearFlags.Skybox) || (camera.clearFlags == CameraClearFlags.Color))
                            {
                                m_CurrentHit[2].target = null;
                                m_CurrentHit[2].camera = null;
                            }
                        }
                    }
                }
            }
            for (int j = 0; j < m_CurrentHit.Length; j++)
            {
                SendEvents(j, m_CurrentHit[j]);
            }
            s_MouseUsed = false;
        }
Ejemplo n.º 10
0
    public static void componentSerialize(string ser)
    {
        GameObject gameObject = null;

        MarkerFlag objMarker = deserializeMarkerFlag(ref ser);

        int hashLoc = genHashCode(objMarker.id);

        int xLoc = hashLoc % 10;
        int yLoc = hashLoc % 100;

        MarkerFlag thisFlag = findInList(objMarker.id, xLoc, yLoc);

        if (thisFlag == null) //Make a new game object with given flag if you need to
        {
            gameObject = new GameObject();
            thisFlag   = gameObject.AddComponent <MarkerFlag>();
        }
        else
        {
            gameObject = thisFlag.gameObject;
        }

        thisFlag.id       = objMarker.id;
        thisFlag.parentID = objMarker.parentID;
        thisFlag.isLocked = objMarker.isLocked;
        if (thisFlag.parentID != "_")
        {
            int        parentHash = genHashCode(thisFlag.parentID);
            int        xParent    = parentHash % 10;
            int        yParent    = parentHash % 100;
            MarkerFlag parentFlag = findInList(thisFlag.parentID, xParent, yParent);
            if (parentFlag != null)
            {
                gameObject.transform.SetParent(parentFlag.gameObject.transform);
            }
            else
            {
                gameObject.transform.SetParent(null);
            }
        }
        else
        {
            gameObject.transform.SetParent(null);
        }

        gameObject.name     = deserializeString(ref ser);
        gameObject.tag      = deserializeString(ref ser);
        gameObject.layer    = deserializeInt(ref ser);
        gameObject.isStatic = deserializeBool(ref ser);
        while (ser.Length > 0)
        {
            string tag = deserializeString(ref ser); //Identifies the component type

            if (tag == "transform")
            {
                UnityEngine.Transform trans = gameObject.transform;
                trans.position   = deserializeVector3(ref ser);
                trans.rotation   = deserializeQuaternion(ref ser);
                trans.localScale = deserializeVector3(ref ser);

                if (expectedObjs > -1)
                {
                    thisFlag.ogPos   = trans.position;
                    thisFlag.ogRot   = trans.rotation;
                    thisFlag.ogScale = trans.localScale;
                }
            }
            else if (tag == "boxCollider")
            {
                UnityEngine.BoxCollider col = gameObject.GetComponent <UnityEngine.BoxCollider>();
                if (col == null)
                {
                    col = gameObject.AddComponent <UnityEngine.BoxCollider>();
                }
                col.center    = deserializeVector3(ref ser);
                col.size      = deserializeVector3(ref ser);
                col.isTrigger = deserializeBool(ref ser);
            }
            else if (tag == "sphereCollider")
            {
                UnityEngine.SphereCollider col = gameObject.GetComponent <UnityEngine.SphereCollider>();
                if (col == null)
                {
                    col = gameObject.AddComponent <UnityEngine.SphereCollider>();
                }
                col.center    = deserializeVector3(ref ser);
                col.radius    = deserializeFloat(ref ser);
                col.isTrigger = deserializeBool(ref ser);
            }
            else if (tag == "capsuleCollider")
            {
                UnityEngine.CapsuleCollider col = gameObject.GetComponent <UnityEngine.CapsuleCollider>();
                if (col == null)
                {
                    col = gameObject.AddComponent <UnityEngine.CapsuleCollider>();
                }
                col.center    = deserializeVector3(ref ser);
                col.radius    = deserializeFloat(ref ser);
                col.height    = deserializeFloat(ref ser);
                col.direction = deserializeInt(ref ser);
                col.isTrigger = deserializeBool(ref ser);
            }
            else if (tag == "rigidbody")
            {
                UnityEngine.Rigidbody col = gameObject.GetComponent <UnityEngine.Rigidbody>();
                if (col == null)
                {
                    col = gameObject.AddComponent <UnityEngine.Rigidbody>();
                }
                col.mass             = deserializeFloat(ref ser);
                col.drag             = deserializeFloat(ref ser);
                col.angularDrag      = deserializeFloat(ref ser);
                col.interpolation    = (RigidbodyInterpolation)deserializeInt(ref ser);
                col.constraints      = (RigidbodyConstraints)deserializeInt(ref ser);
                col.useGravity       = deserializeBool(ref ser);
                col.isKinematic      = deserializeBool(ref ser);
                col.detectCollisions = deserializeBool(ref ser);
            }
            else if (tag == "camera")
            {
                UnityEngine.Camera cam = gameObject.GetComponent <UnityEngine.Camera>();
                if (cam == null)
                {
                    cam = gameObject.AddComponent <UnityEngine.Camera>();
                }
                cam.clearFlags          = (CameraClearFlags)deserializeInt(ref ser);
                cam.backgroundColor     = deserializeColor(ref ser);
                cam.cullingMask         = deserializeInt(ref ser);
                cam.nearClipPlane       = deserializeFloat(ref ser);
                cam.farClipPlane        = deserializeFloat(ref ser);
                cam.rect                = deserializeRect(ref ser);
                cam.renderingPath       = (RenderingPath)deserializeInt(ref ser);
                cam.allowHDR            = deserializeBool(ref ser);
                cam.allowMSAA           = deserializeBool(ref ser);
                cam.useOcclusionCulling = deserializeBool(ref ser);
                cam.depth               = deserializeFloat(ref ser);
                cam.fieldOfView         = deserializeFloat(ref ser);
                cam.targetDisplay       = deserializeInt(ref ser);
            }
            else if (tag == "light")
            {
                UnityEngine.Light li = gameObject.GetComponent <UnityEngine.Light>();
                if (li == null)
                {
                    li = gameObject.AddComponent <UnityEngine.Light>();
                }
                li.type        = (LightType)deserializeInt(ref ser);
                li.shadows     = (LightShadows)deserializeInt(ref ser);
                li.renderMode  = (LightRenderMode)deserializeInt(ref ser);
                li.cullingMask = deserializeInt(ref ser);
                li.color       = deserializeColor(ref ser);
                li.intensity   = deserializeFloat(ref ser);
                li.cookieSize  = deserializeFloat(ref ser);
            }
            else if (tag == "meshfilter")
            {
                UnityEngine.MeshFilter meshFilter = gameObject.GetComponent <UnityEngine.MeshFilter>();
                if (meshFilter == null)
                {
                    meshFilter = gameObject.AddComponent <UnityEngine.MeshFilter>();
                }
                string filePath = deserializeString(ref ser);
                string meshName = deserializeString(ref ser);

                UnityEngine.Object[] assets = AssetDatabase.LoadAllAssetsAtPath(filePath);
                for (int x = 0; x < assets.Length; ++x)
                {
                    if (assets[x].name == meshName)
                    {
                        gameObject.GetComponent <UnityEngine.MeshFilter>().mesh = assets[x] as UnityEngine.Mesh;
                        break;
                    }
                }
            }
            else if (tag == "meshRenderer")
            {
                UnityEngine.MeshRenderer gOMeshRenderer = gameObject.GetComponent <UnityEngine.MeshRenderer>();
                if (gOMeshRenderer == null)
                {
                    gOMeshRenderer = gameObject.AddComponent <UnityEngine.MeshRenderer>();
                }

                gOMeshRenderer.lightProbeUsage            = (UnityEngine.Rendering.LightProbeUsage)deserializeInt(ref ser);
                gOMeshRenderer.reflectionProbeUsage       = (UnityEngine.Rendering.ReflectionProbeUsage)deserializeInt(ref ser);
                gOMeshRenderer.shadowCastingMode          = (UnityEngine.Rendering.ShadowCastingMode)deserializeInt(ref ser);
                gOMeshRenderer.receiveShadows             = deserializeBool(ref ser);
                gOMeshRenderer.motionVectorGenerationMode = (UnityEngine.MotionVectorGenerationMode)deserializeInt(ref ser);
                //Light map static junk
                deserializeBool(ref ser);

                string          materialsList   = deserializeString(ref ser);
                List <Material> renderMaterials = new List <Material>();
                if (materialsList.Length > 1)
                {
                    while (materialsList != "")
                    {
                        int length = materialsList.IndexOf(",");
                        if (length > 0)
                        {
                            string ret = materialsList.Substring(0, length);
                            materialsList = materialsList.Remove(0, length + 1);
                            Material newMat = null;
                            if (ret == "Default-Material" || ret == "" || ret == "Resources/unity_builtin_extra")
                            {
                                newMat = AssetDatabase.GetBuiltinExtraResource <Material>("Default-Diffuse.mat");
                            }
                            else
                            {
                                newMat = (Material)AssetDatabase.LoadAssetAtPath(ret, typeof(Material));
                            }

                            renderMaterials.Add(newMat);
                        }
                    }
                    if (renderMaterials.Count > 0)
                    {
                        gOMeshRenderer.GetComponent <Renderer>().materials = renderMaterials.ToArray();
                    }
                }
            }
            else if (tag == "guilayer")
            {
                UnityEngine.GUILayer gOGuiLayer = gameObject.GetComponent <GUILayer>();
                if (gOGuiLayer == null)
                {
                    gOGuiLayer = gameObject.AddComponent <GUILayer>();
                }
            }
            else if (tag == "flarelayer")
            {
                UnityEngine.FlareLayer gOFlareLayer = gameObject.GetComponent <FlareLayer>();
                if (gOFlareLayer == null)
                {
                    gOFlareLayer = gameObject.AddComponent <FlareLayer>();
                }
            }
            else if (tag == "audiolistener")
            {
                UnityEngine.AudioListener gOAudioListener = gameObject.GetComponent <AudioListener>();
                if (gOAudioListener == null)
                {
                    gOAudioListener = gameObject.AddComponent <AudioListener>();
                }
            }
            else
            {
                Debug.Log("Unkown Componenet Type " + tag);
            }
        }
        addToMap(thisFlag);
    }
Ejemplo n.º 11
0
    public static string serialize(GameObject obj)
    {
        string serialized = "";                        //Message.GO_UPDATE.ToString();

        serMarkerFlag serMarker = new serMarkerFlag(); //Put the marker flag info on the string first !!!

        serMarker.flag = obj.GetComponent <MarkerFlag>();

        if (obj.transform.parent == null)
        {
            serMarker.flag.parentID = "__";
        }
        else
        {
            serMarker.flag.parentID = obj.transform.parent.GetComponent <MarkerFlag>().id;
        }

        string flagData = new string(serMarker.toChar());

        serialized += flagData;

        int hashLoc = genHashCode(serMarker.flag.id);
        int xLoc    = hashLoc % 10;
        int yLoc    = hashLoc % 100;

        //TODO check location if it already is there
        objectMap[xLoc, yLoc].Add(serMarker.flag);

        serialized += obj.name + "|";
        serialized += obj.tag + "|";
        serialized += obj.layer + "|";
        serialized += obj.isStatic + "|";
        Component[] comps;
        comps = obj.GetComponents <Component>();
        for (int i = 0; i < comps.Length; i++)
        {
            if (comps[i] != null)
            {
                if (comps[i].GetType() == typeof(UnityEngine.Transform))
                {
                    UnityEngine.Transform newTransform = comps[i] as UnityEngine.Transform;

                    Transform serNewTransform = new Transform();
                    serNewTransform.pos   = newTransform.position;
                    serNewTransform.rot   = newTransform.rotation;
                    serNewTransform.scale = newTransform.localScale;
                    string transformString = new string(serNewTransform.toChar());
                    serialized += transformString;
                }
                else if (comps[i].GetType() == typeof(UnityEngine.BoxCollider))
                {
                    UnityEngine.BoxCollider newBoxCollider = comps[i] as UnityEngine.BoxCollider;

                    BoxCollider serNewBoxCollider = new BoxCollider();
                    serNewBoxCollider.center    = newBoxCollider.center;
                    serNewBoxCollider.size      = newBoxCollider.size;
                    serNewBoxCollider.isTrigger = newBoxCollider.isTrigger;
                    string boxColliderString = new string(serNewBoxCollider.toChar());
                    serialized += boxColliderString;
                }
                else if (comps[i].GetType() == typeof(UnityEngine.SphereCollider))
                {
                    UnityEngine.SphereCollider newSphereCollider = comps[i] as UnityEngine.SphereCollider;

                    SphereCollider serNewSphereCollider = new SphereCollider();
                    serNewSphereCollider.center    = newSphereCollider.center;
                    serNewSphereCollider.radius    = newSphereCollider.radius;
                    serNewSphereCollider.isTrigger = newSphereCollider.isTrigger;
                    string sphereColliderString = new string(serNewSphereCollider.toChar());
                    serialized += sphereColliderString;
                }
                else if (comps[i].GetType() == typeof(UnityEngine.CapsuleCollider))
                {
                    UnityEngine.CapsuleCollider newCapsuleCollider = comps[i] as UnityEngine.CapsuleCollider;

                    CapsuleCollider serNewCapsuleCollider = new CapsuleCollider();
                    serNewCapsuleCollider.center        = newCapsuleCollider.center;
                    serNewCapsuleCollider.radius        = newCapsuleCollider.radius;
                    serNewCapsuleCollider.height        = newCapsuleCollider.height;
                    serNewCapsuleCollider.directionAxis = newCapsuleCollider.direction;
                    serNewCapsuleCollider.isTrigger     = newCapsuleCollider.isTrigger;
                    string capsuleColliderString = new string(serNewCapsuleCollider.toChar());
                    serialized += capsuleColliderString;
                }
                else if (comps[i].GetType() == typeof(UnityEngine.Rigidbody))
                {
                    UnityEngine.Rigidbody newRigidBody = comps[i] as UnityEngine.Rigidbody;

                    RigidBody serNewRigidBody = new RigidBody();
                    serNewRigidBody.mass               = newRigidBody.mass;
                    serNewRigidBody.drag               = newRigidBody.drag;
                    serNewRigidBody.angularDrag        = newRigidBody.angularDrag;
                    serNewRigidBody.interpolate        = (int)newRigidBody.interpolation;
                    serNewRigidBody.collisionDetection = newRigidBody.detectCollisions;
                    serNewRigidBody.freeze             = (int)newRigidBody.constraints;
                    serNewRigidBody.isKinematic        = newRigidBody.isKinematic;
                    serNewRigidBody.useGravity         = newRigidBody.useGravity;
                    serNewRigidBody.collisionDetection = newRigidBody.detectCollisions;
                    string rigidBodyString = new string(serNewRigidBody.toChar());
                    serialized += rigidBodyString;
                }
                else if (comps[i].GetType() == typeof(UnityEngine.Camera))
                {
                    UnityEngine.Camera newCamera = comps[i] as UnityEngine.Camera;

                    Camera serNewCamera = new Camera();
                    serNewCamera.clearFlags       = (int)newCamera.clearFlags;
                    serNewCamera.background       = newCamera.backgroundColor;
                    serNewCamera.cullingMask      = newCamera.cullingMask;
                    serNewCamera.projection       = newCamera.projectionMatrix.ToString();
                    serNewCamera.near             = newCamera.nearClipPlane;
                    serNewCamera.far              = newCamera.farClipPlane;
                    serNewCamera.viewportRect     = newCamera.rect;
                    serNewCamera.renderingPath    = (int)newCamera.renderingPath;
                    serNewCamera.HDR              = newCamera.allowHDR;
                    serNewCamera.MSAA             = newCamera.allowMSAA;
                    serNewCamera.occlusionCulling = newCamera.useOcclusionCulling;
                    serNewCamera.depth            = newCamera.depth;
                    serNewCamera.fov              = newCamera.fieldOfView;
                    serNewCamera.targetDisplay    = newCamera.targetDisplay;

                    string cameraString = new string(serNewCamera.toChar());
                    serialized += cameraString;
                }
                else if (comps[i].GetType() == typeof(UnityEngine.MeshFilter))
                {
                    //Gather Meshfilter information on current GO
                    UnityEngine.MeshFilter gOMeshFilter = comps[i] as UnityEngine.MeshFilter;
                    Mesh gOMesh = gOMeshFilter.sharedMesh;


                    //Pack data into our meshfilter object
                    MeshFilter meshStruct = new MeshFilter();
                    meshStruct.filePath = AssetDatabase.GetAssetPath(gOMesh);
                    meshStruct.meshName = gOMesh.name;

                    //Convert the data into a string and add it to the overall data stream
                    string sStream = new string(meshStruct.toChar());
                    serialized += sStream;
                }
                else if (comps[i].GetType() == typeof(UnityEngine.MeshRenderer))
                {
                    UnityEngine.MeshRenderer gOMeshRenderer = comps[i] as UnityEngine.MeshRenderer;


                    //Pack data into our MeshRenderer obj
                    MeshRenderer meshStruct = new MeshRenderer();
                    meshStruct.lightProbe      = (int)gOMeshRenderer.lightProbeUsage;
                    meshStruct.reflectionProbe = (int)gOMeshRenderer.reflectionProbeUsage;
                    meshStruct.castShadows     = (int)gOMeshRenderer.shadowCastingMode;
                    meshStruct.receiveShadows  = gOMeshRenderer.receiveShadows;
                    meshStruct.motionVectors   = (int)gOMeshRenderer.motionVectorGenerationMode;
                    meshStruct.lightmapStatic  = false;

                    Material[] gOMaterials = gOMeshRenderer.sharedMaterials;
                    for (int q = 0; q < gOMaterials.Length; ++q)
                    {
                        string materialPath = "";
                        if (gOMaterials[q] == null || gOMaterials[q].name == "Default-Material")
                        {
                            materialPath = "Default-Material";
                        }
                        else
                        {
                            materialPath = AssetDatabase.GetAssetPath(gOMaterials[q]);
                        }
                        meshStruct.materialFiles.Add(materialPath);
                    }

                    string sStream = new string(meshStruct.toChar());
                    serialized += sStream;
                }
                else if (comps[i].GetType() == typeof(UnityEngine.Light))
                {
                    UnityEngine.Light newLight = comps[i] as UnityEngine.Light;

                    Light serNewLight = new Light();
                    serNewLight.type        = (int)newLight.type;
                    serNewLight.shadows     = (int)newLight.shadows;
                    serNewLight.mode        = (int)newLight.renderMode;
                    serNewLight.cullingMask = newLight.cullingMask;
                    serNewLight.color       = newLight.color;
                    serNewLight.intensity   = newLight.intensity;
                    serNewLight.cookie      = newLight.cookieSize;

                    string lightString = new string(serNewLight.toChar());
                    serialized += lightString;
                }
                else if (comps[i].GetType() == typeof(UnityEngine.GUILayer))
                {
                    UnityEngine.GUILayer newGuiLayer = comps[i] as UnityEngine.GUILayer;

                    string lightString = "guilayer|";
                    serialized += lightString;
                }
                else if (comps[i].GetType() == typeof(UnityEngine.FlareLayer))
                {
                    UnityEngine.FlareLayer newGuiLayer = comps[i] as UnityEngine.FlareLayer;

                    string lightString = "flarelayer|";
                    serialized += lightString;
                }
                else if (comps[i].GetType() == typeof(UnityEngine.AudioListener))
                {
                    UnityEngine.AudioListener newGuiLayer = comps[i] as UnityEngine.AudioListener;

                    string lightString = "audiolistener|";
                    serialized += lightString;
                }
            }
        }

        return(serialized);
    }
Ejemplo n.º 12
0
 private static GUIElement INTERNAL_CALL_HitTest(GUILayer self, ref Vector3 screenPosition)
 {
     throw new NotImplementedException("‚È‚É‚±‚ê");
 }
Ejemplo n.º 13
0
        public void CreateCamera()
        {
            this.MainCamera    = UnityEngine.Camera.main;
            this.MainCameraFOV = this.MainCamera.fieldOfView;
            if (this.CameraFoV == 0)
            {
                this.CameraFoV = this.MainCameraFOV;
            }
            if (this.CameraNearClip == 0)
            {
                this.CameraNearClip = this.MainCamera.nearClipPlane;
            }
            if (this.CameraForClip == 0)
            {
                this.CameraForClip = this.MainCamera.farClipPlane;
            }
            this.MainCamera.enabled = false;
            // free camera on
            this.MainCamera.GetComponent <RideCameraController>().ONGNOMCJBGE = true;
            // copy camera object
            this.CameraObject      = UnityEngine.Object.Instantiate(this.MainCamera.gameObject);
            this.CameraObject.name = "Camera";
            this.Camera            = this.CameraObject.GetComponent <UnityEngine.Camera>();
            this.Camera.enabled    = true;
            this.CameraTransform   = this.CameraObject.transform;
            if (this.RootObject != null)
            {
                this.CameraTransform.SetParent(this.RootObject.transform);
            }
            this.CameraObject.transform.position = this.MainCamera.transform.position;
            // delete components
            UnityEngine.AudioListener audioLis = this.CameraObject.GetComponent <UnityEngine.AudioListener>();
            if (audioLis != null)
            {
                UnityEngine.Object.DestroyImmediate(audioLis);
            }
            audioLis = null;

            UnityEngine.GUILayer guilayer = this.CameraObject.GetComponent <UnityEngine.GUILayer>();
            if (guilayer != null)
            {
                UnityEngine.Object.DestroyImmediate(guilayer);
            }
            guilayer = null;

            RideCameraController rideCamCntrl = this.CameraObject.GetComponent <RideCameraController>();

            rideCamCntrl.ONGNOMCJBGE = true;
            if (rideCamCntrl != null)
            {
                UnityEngine.Object.DestroyImmediate(rideCamCntrl);
            }
            rideCamCntrl = null;

            Skybox skybox = this.CameraObject.GetComponent <Skybox>();

            if (skybox != null)
            {
                UnityEngine.Object.DestroyImmediate(skybox);
            }
            skybox = null;

            this.cameraDestoryer = CameraDestoryer.Create(this);
        }
Ejemplo n.º 14
0
        private static void DoSendMouseEvents(int skipRTCameras)
        {
            Vector3 mousePosition   = Input.mousePosition;
            int     allCamerasCount = Camera.allCamerasCount;

            if (m_Cameras == null || m_Cameras.Length != allCamerasCount)
            {
                m_Cameras = new Camera[allCamerasCount];
            }
            Camera.GetAllCameras(m_Cameras);
            for (int i = 0; i < m_CurrentHit.Length; i++)
            {
                m_CurrentHit[i] = default(HitInfo);
            }
            if (!s_MouseUsed)
            {
                Camera[] cameras = m_Cameras;
                foreach (Camera camera in cameras)
                {
                    if (camera == null || (skipRTCameras != 0 && camera.targetTexture != null))
                    {
                        continue;
                    }
                    int     targetDisplay = camera.targetDisplay;
                    Vector3 vector        = Display.RelativeMouseAt(mousePosition);
                    if (vector != Vector3.zero)
                    {
                        int num = (int)vector.z;
                        if (num != targetDisplay)
                        {
                            continue;
                        }
                        float num2 = Screen.width;
                        float num3 = Screen.height;
                        if (targetDisplay > 0 && targetDisplay < Display.displays.Length)
                        {
                            num2 = Display.displays[targetDisplay].systemWidth;
                            num3 = Display.displays[targetDisplay].systemHeight;
                        }
                        Vector2 vector2 = new Vector2(vector.x / num2, vector.y / num3);
                        if (vector2.x < 0f || vector2.x > 1f || vector2.y < 0f || vector2.y > 1f)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        vector = mousePosition;
                        if (!camera.pixelRect.Contains(vector))
                        {
                            continue;
                        }
                    }
                    GUILayer component = camera.GetComponent <GUILayer>();
                    if ((bool)component)
                    {
                        GUIElement gUIElement = component.HitTest(vector);
                        if ((bool)gUIElement)
                        {
                            m_CurrentHit[0].target = gUIElement.gameObject;
                            m_CurrentHit[0].camera = camera;
                        }
                        else
                        {
                            m_CurrentHit[0].target = null;
                            m_CurrentHit[0].camera = null;
                        }
                    }
                    if (camera.eventMask != 0)
                    {
                        Ray        ray        = camera.ScreenPointToRay(vector);
                        Vector3    direction  = ray.direction;
                        float      z          = direction.z;
                        float      distance   = (!Mathf.Approximately(0f, z)) ? Mathf.Abs((camera.farClipPlane - camera.nearClipPlane) / z) : float.PositiveInfinity;
                        GameObject gameObject = camera.RaycastTry(ray, distance, camera.cullingMask & camera.eventMask);
                        if (gameObject != null)
                        {
                            m_CurrentHit[1].target = gameObject;
                            m_CurrentHit[1].camera = camera;
                        }
                        else if (camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.Color)
                        {
                            m_CurrentHit[1].target = null;
                            m_CurrentHit[1].camera = null;
                        }
                        GameObject gameObject2 = camera.RaycastTry2D(ray, distance, camera.cullingMask & camera.eventMask);
                        if (gameObject2 != null)
                        {
                            m_CurrentHit[2].target = gameObject2;
                            m_CurrentHit[2].camera = camera;
                        }
                        else if (camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.Color)
                        {
                            m_CurrentHit[2].target = null;
                            m_CurrentHit[2].camera = null;
                        }
                    }
                }
            }
            for (int k = 0; k < m_CurrentHit.Length; k++)
            {
                SendEvents(k, m_CurrentHit[k]);
            }
            s_MouseUsed = false;
        }