Пример #1
0
        public static void PrepAssetForScreenSize(object asset)
        {
            GameObject gameObject = asset as GameObject;

            if (gameObject == null)
            {
                return;
            }
            GameObject gameObject2 = UnityUtils.FindGameObject(gameObject, "WidgetSafeArea");

            if (gameObject2 == null)
            {
                return;
            }
            UIWidget component = gameObject2.GetComponent <UIWidget>();
            Rect     safeArea  = SafeScreenUtils.GetSafeArea();

            if (safeArea.width < (float)Screen.width || safeArea.height < (float)Screen.height || safeArea.x > 0f || safeArea.y > 0f)
            {
                if (SafeScreenUtils.useFixedAnchors)
                {
                    component.leftAnchor.absolute   = 53;
                    component.topAnchor.absolute    = 0;
                    component.rightAnchor.absolute  = -53;
                    component.bottomAnchor.absolute = 0;
                }
                else
                {
                    component.leftAnchor.absolute   = (int)safeArea.x;
                    component.topAnchor.absolute    = (int)safeArea.y;
                    component.rightAnchor.absolute  = (int)(safeArea.width - (float)Screen.width);
                    component.bottomAnchor.absolute = (int)(safeArea.height - (float)Screen.height);
                }
            }
        }
Пример #2
0
        public static GameObject CreateChildGameObject(string name, GameObject parentGameObject)
        {
            GameObject gameObject = new GameObject(name);

            gameObject.layer = parentGameObject.layer;
            UnityUtils.ChangeGameObjectParent(gameObject, parentGameObject);
            return(gameObject);
        }
Пример #3
0
        public static Mesh CreateMeshWithVertices(Vector3[] vertices, Vector2[] uv, int[] triangles)
        {
            Mesh mesh = UnityUtils.CreateMesh();

            mesh.vertices  = vertices;
            mesh.uv        = uv;
            mesh.triangles = triangles;
            mesh.RecalculateNormals();
            return(mesh);
        }
Пример #4
0
        public static void SetLayerRecursively(GameObject gameObject, int layer)
        {
            gameObject.layer = layer;
            Transform transform  = gameObject.transform;
            int       i          = 0;
            int       childCount = transform.childCount;

            while (i < childCount)
            {
                UnityUtils.SetLayerRecursively(transform.GetChild(i).gameObject, layer);
                i++;
            }
        }
Пример #5
0
        public static void EnableColliders(GameObject gameObject, bool enable)
        {
            Collider component = gameObject.GetComponent <Collider>();

            if (component != null)
            {
                component.enabled = enable;
            }
            int i          = 0;
            int childCount = gameObject.transform.childCount;

            while (i < childCount)
            {
                UnityUtils.EnableColliders(gameObject.transform.GetChild(i).gameObject, enable);
                i++;
            }
        }
Пример #6
0
        public static void RemoveColliders(GameObject gameObject)
        {
            Collider component = gameObject.GetComponent <Collider>();

            if (component != null)
            {
                UnityEngine.Object.Destroy(component);
            }
            int i          = 0;
            int childCount = gameObject.transform.childCount;

            while (i < childCount)
            {
                UnityUtils.RemoveColliders(gameObject.transform.GetChild(i).gameObject);
                i++;
            }
        }
Пример #7
0
        public static bool GetRayEllipsoidIntersection(Vector3 rayOrigin, Vector3 rayDir, Vector3 ellipseOrigin, Vector3 ellipseRadius, out Vector3 intersectionPoint)
        {
            Vector3 vector  = UnityUtils.Divide(rayDir, ellipseRadius);
            Vector3 vector2 = UnityUtils.Divide(rayOrigin - ellipseOrigin, ellipseRadius);
            float   num     = Vector3.Dot(vector, vector);
            float   num2    = 2f * Vector3.Dot(vector2, vector);
            float   num3    = Vector3.Dot(vector2, vector2) - 1f;
            float   num4    = num2 * num2 - 4f * num * num3;

            if (num4 < 0f)
            {
                intersectionPoint = Vector3.zero;
                return(false);
            }
            float d = (-num2 - Mathf.Sqrt(num4)) / (2f * num);

            intersectionPoint = rayOrigin + d * rayDir;
            return(true);
        }
Пример #8
0
        public static Material CreateBuildingColorMaterial()
        {
            Material     material     = null;
            AssetManager assetManager = Service.Get <AssetManager>();

            if (assetManager != null)
            {
                GameShaders shaders = assetManager.Shaders;
                if (shaders != null)
                {
                    Shader shader = shaders.GetShader("Grid_Building_Color_PL");
                    material = UnityUtils.CreateMaterial(shader);
                }
            }
            if (material == null)
            {
                throw new Exception("Unable to create color material");
            }
            return(material);
        }
Пример #9
0
 public static Mesh CreateQuadMesh(float border)
 {
     Vector3[] array  = new Vector3[4];
     Vector2[] array2 = new Vector2[4];
     int[]     array3 = new int[6];
     array[0]  = new Vector3(0f + border, 0f, 0f + border);
     array[1]  = new Vector3(1f - border, 0f, 0f + border);
     array[2]  = new Vector3(1f - border, 0f, 1f - border);
     array[3]  = new Vector3(0f + border, 0f, 1f - border);
     array2[0] = new Vector2(0f, 0f);
     array2[1] = new Vector2(1f, 0f);
     array2[2] = new Vector2(1f, 1f);
     array2[3] = new Vector2(0f, 1f);
     array3[0] = 0;
     array3[1] = 2;
     array3[2] = 1;
     array3[3] = 0;
     array3[4] = 3;
     array3[5] = 2;
     return(UnityUtils.CreateMeshWithVertices(array, array2, array3));
 }
Пример #10
0
        public static Material CreateColorMaterial(Color32 color)
        {
            Material     material     = null;
            AssetManager assetManager = Service.Get <AssetManager>();

            if (assetManager != null)
            {
                GameShaders shaders = assetManager.Shaders;
                if (shaders != null)
                {
                    Shader shader = shaders.GetShader("SimpleSolidColor");
                    material = UnityUtils.CreateMaterial(shader);
                }
            }
            if (material == null)
            {
                throw new Exception("Unable to create color material");
            }
            material.SetColor("_Pigment", color);
            return(material);
        }
Пример #11
0
        public static GameObject FindGameObject(GameObject parent, string name)
        {
            if (parent.name == name)
            {
                return(parent);
            }
            Transform transform  = parent.transform;
            int       i          = 0;
            int       childCount = transform.childCount;

            while (i < childCount)
            {
                GameObject gameObject = UnityUtils.FindGameObject(transform.GetChild(i).gameObject, name);
                if (gameObject != null)
                {
                    return(gameObject);
                }
                i++;
            }
            return(null);
        }
Пример #12
0
 public unsafe static long $Invoke28(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(UnityUtils.HasRendererMaterial((Renderer)GCHandledObjects.GCHandleToObject(*args))));
 }
Пример #13
0
 public unsafe static long $Invoke27(long instance, long *args)
 {
     UnityUtils.HandleUnityLog(Marshal.PtrToStringUni(*(IntPtr *)args), Marshal.PtrToStringUni(*(IntPtr *)(args + 1)), (LogType)(*(int *)(args + 2)));
     return(-1L);
 }
Пример #14
0
 public unsafe static long $Invoke37(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(UnityUtils.ShouldIgnoreUIGameObjectInRaycast((GameObject)GCHandledObjects.GCHandleToObject(*args))));
 }
Пример #15
0
 public unsafe static long $Invoke35(long instance, long *args)
 {
     UnityUtils.SetQuadVertices(*(float *)args, *(float *)(args + 1), *(float *)(args + 2), *(float *)(args + 3), *(int *)(args + 4), (Vector3[])GCHandledObjects.GCHandleToPinnedArrayObject(args[5]));
     return(-1L);
 }
Пример #16
0
 public unsafe static long $Invoke33(long instance, long *args)
 {
     UnityUtils.ScaleParticleSize((ParticleSystem)GCHandledObjects.GCHandleToObject(*args), *(float *)(args + 1), *(float *)(args + 2));
     return(-1L);
 }
Пример #17
0
 public unsafe static long $Invoke31(long instance, long *args)
 {
     UnityUtils.RegisterLogCallback(Marshal.PtrToStringUni(*(IntPtr *)args), (UnityUtils.OnUnityLogCallback)GCHandledObjects.GCHandleToObject(args[1]));
     return(-1L);
 }
Пример #18
0
 public unsafe static long $Invoke29(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(UnityUtils.IsWideScreen()));
 }
Пример #19
0
 public unsafe static long $Invoke30(long instance, long *args)
 {
     UnityUtils.PlayParticleEmitter((ParticleSystem)GCHandledObjects.GCHandleToObject(*args));
     return(-1L);
 }
Пример #20
0
 public unsafe static long $Invoke19(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(UnityUtils.FindGameObject((GameObject)GCHandledObjects.GCHandleToObject(*args), Marshal.PtrToStringUni(*(IntPtr *)(args + 1)))));
 }
Пример #21
0
 public unsafe static long $Invoke32(long instance, long *args)
 {
     UnityUtils.RemoveColliders((GameObject)GCHandledObjects.GCHandleToObject(*args));
     return(-1L);
 }
Пример #22
0
 public unsafe static long $Invoke20(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(UnityUtils.GetAnimationWrapMode((Animation)GCHandledObjects.GCHandleToObject(*args), (AnimationState)GCHandledObjects.GCHandleToObject(args[1]))));
 }
Пример #23
0
 public unsafe static long $Invoke34(long instance, long *args)
 {
     UnityUtils.SetLayerRecursively((GameObject)GCHandledObjects.GCHandleToObject(*args), *(int *)(args + 1));
     return(-1L);
 }
Пример #24
0
 public unsafe static long $Invoke21(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(UnityUtils.GetChildren((GameObject)GCHandledObjects.GCHandleToObject(*args))));
 }
Пример #25
0
 public unsafe static long $Invoke36(long instance, long *args)
 {
     UnityUtils.SetupMeshMaterial((GameObject)GCHandledObjects.GCHandleToObject(*args), (Mesh)GCHandledObjects.GCHandleToObject(args[1]), (Material)GCHandledObjects.GCHandleToObject(args[2]));
     return(-1L);
 }
Пример #26
0
 public unsafe static long $Invoke24(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(UnityUtils.GetGameObjectLocalBounds((GameObject)GCHandledObjects.GCHandleToObject(*args), *(sbyte *)(args + 1) != 0)));
 }
Пример #27
0
 public unsafe static long $Invoke38(long instance, long *args)
 {
     UnityUtils.StaticReset();
     return(-1L);
 }
Пример #28
0
 public unsafe static long $Invoke25(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(UnityUtils.GetRealTimeSinceStartUp()));
 }
Пример #29
0
 public static float GetRealTimeSinceStartUpInMilliseconds()
 {
     return(Mathf.Round(UnityUtils.GetRealTimeSinceStartUp() * 1000f));
 }
Пример #30
0
 public unsafe static long $Invoke26(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(UnityUtils.GetRelativeGameObjectBounds((GameObject)GCHandledObjects.GCHandleToObject(*args))));
 }