public static DateTime GetNetworkDateTime()
 {
     if (methodGetNetworkDateTime == null)
     {
         methodGetNetworkDateTime = Instance_Class.GetMethods().First(x => x.GetReturnType().Name == "System.DateTime");
         if (methodGetNetworkDateTime == null)
         {
             return(DateTime.Now);
         }
     }
     return(methodGetNetworkDateTime.Invoke().Unbox <DateTime>());
 }
Exemple #2
0
        public static Player[] GetAllPlayers()
        {
            if (methodGetAllPlayers == null)
            {
                methodGetAllPlayers = Instance_Class.GetMethods().First(x => x.GetReturnType().Name == "VRC.Player[]" && x.HasFlag(IL2BindingFlags.METHOD_STATIC));
                if (methodGetAllPlayers == null)
                {
                    return(null);
                }
            }

            return(methodGetAllPlayers.Invoke().UnboxArray <Player>());
        }
        public static int?GetOwnerId(GameObject obj)
        {
            if (methodGetOwnerId == null)
            {
                methodGetOwnerId = Instance_Class.GetMethods().First(x => x.GetReturnType().Name == "System.Nullable<System.Int32>");
                if (methodGetOwnerId == null)
                {
                    return(null);
                }
            }

            return(methodGetOwnerId.Invoke(IntPtr.Zero, new IntPtr[] { obj.ptr })?.Unbox <int>());
        }
Exemple #4
0
        public static float GammaToLinearSpace(float value)
        {
            if (methodGammaToLinearSpace == null)
            {
                methodGammaToLinearSpace = Instance_Class.GetMethod("GammaToLinearSpace");
                if (methodGammaToLinearSpace == null)
                {
                    return(0);
                }
            }

            IL2Object result = methodGammaToLinearSpace.Invoke(new IntPtr[] { value.MonoCast() });

            if (result == null)
            {
                return(default);
Exemple #5
0
        public static Object[] FindObjectsOfTypeAll(Type type)
        {
            if (methodFindObjectsOfTypeAll == null)
            {
                methodFindObjectsOfTypeAll = Instance_Class.GetMethods()
                                             .Where(x => x.Name == "FindObjectsOfTypeAll")
                                             .First(x => x.GetReturnType().Name == "UnityEngine.Object[]");
                if (methodFindObjectsOfTypeAll == null)
                {
                    return(null);
                }
            }

            IL2TypeObject typeObject = IL2GetType.IL2Typeof(type);

            if (typeObject == null)
            {
                return(null);
            }

            return(methodFindObjectsOfTypeAll.Invoke(new IntPtr[] { typeObject.ptr }).UnboxArray <Object>());
        }