Ejemplo n.º 1
0
    public static void SetTargetFrameRate(int frameRate)
    {
        if (frameRate == 0)
        {
            if (singleton != null)
            {
                DestroyImmediate(singleton);
                singleton = null;
            }

            targetDeltaTicks = 0;
            return;
        }

        targetDeltaTicks = Mathf.RoundToInt(1000f / frameRate + BONUS_TICKS);

        if (singleton != null)
        {
            return;
        }

        var go = new GameObject("uLinkTargetFrameRateFix");

        go.AddComponent <uLinkTargetFrameRateFix>();
        go.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector | HideFlags.NotEditable;
    }
Ejemplo n.º 2
0
    void Awake()
    {
        if (singleton != null)
        {
            DestroyImmediate(this);
            return;
        }

        singleton = this;

        DontDestroyOnLoad(this);

        prevTicksSinceStartup = timeGetTime();
    }
	void Awake()
	{
		if (singleton != null)
		{
			DestroyImmediate(this);
			return;
		}

		singleton = this;

		DontDestroyOnLoad(this);

		prevTicksSinceStartup = timeGetTime();
	}
Ejemplo n.º 4
0
    public static void SetTargetFrameRate(int frameRate)
    {
        if (QualitySettings.vSyncCount != 0)
        {
            return;
        }

        UnityEngine.Application.targetFrameRate = -1;

        if (UnityEngine.Application.platform != RuntimePlatform.WindowsPlayer)
        {
            UnityEngine.Application.targetFrameRate = frameRate;
            return;
        }

        try         // make sure there is no issues calling these two native Win32 APIs
        {
            timeGetTime();
            MsgWaitForMultipleObjectsEx(0, null, 0, 0, 0);
        }
        catch (Exception)
        {
            UnityEngine.Application.targetFrameRate = frameRate;
            return;
        }

        if (frameRate == 0 || frameRate == -1)
        {
            if (singleton != null)
            {
                DestroyImmediate(singleton);
                singleton = null;
            }

            targetDeltaTicks = 0;
            return;
        }

        targetDeltaTicks = Mathf.RoundToInt(1000f / frameRate + BONUS_TICKS);

        if (singleton != null)
        {
            return;
        }

        var go = new GameObject("uLinkTargetFrameRateFix", typeof(uLinkTargetFrameRateFix));

        go.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector | HideFlags.NotEditable | HideFlags.DontSave;
    }
    public static bool SetTargetFrameRate(int frameRate)
    {
        if (UnityEngine.Application.platform != RuntimePlatform.WindowsPlayer)
        {
            return(false);
        }

        try         // make sure there is no issues calling these two native Win32 APIs
        {
            timeGetTime();
            MsgWaitForMultipleObjectsEx(0, null, 0, 0, 0);
        }
        catch (Exception)
        {
            return(false);
        }

        if (frameRate == 0)
        {
            if (singleton != null)
            {
                DestroyImmediate(singleton);
                singleton = null;
            }

            targetDeltaTicks = 0;
            return(true);
        }

        targetDeltaTicks = Mathf.RoundToInt(1000f / frameRate + BONUS_TICKS);

        if (singleton != null)
        {
            return(true);
        }

        var go = new GameObject("uLinkTargetFrameRateFix");

        go.AddComponent <uLinkTargetFrameRateFix>();
        go.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector | HideFlags.NotEditable;

        return(true);
    }
	public static void SetTargetFrameRate(int frameRate)
	{
		if (frameRate == 0)
		{
			if (singleton != null)
			{
				DestroyImmediate(singleton);
				singleton = null;
			}

			targetDeltaTicks = 0;
			return;
		}

		targetDeltaTicks = Mathf.RoundToInt(1000f / frameRate + BONUS_TICKS);
		
		if (singleton != null) return;

		var go = new GameObject("uLinkTargetFrameRateFix");
		go.AddComponent<uLinkTargetFrameRateFix>();
		go.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector | HideFlags.NotEditable;
	}
	public static bool SetTargetFrameRate(int frameRate)
	{
		if (UnityEngine.Application.platform != RuntimePlatform.WindowsPlayer) return false;

		try // make sure there is no issues calling these two native Win32 APIs
		{
			timeGetTime();
			MsgWaitForMultipleObjectsEx(0, null, 0, 0, 0);
		}
		catch (Exception)
		{
			return false;
		}

		if (frameRate == 0)
		{
			if (singleton != null)
			{
				DestroyImmediate(singleton);
				singleton = null;
			}

			targetDeltaTicks = 0;
			return true;
		}

		targetDeltaTicks = Mathf.RoundToInt(1000f / frameRate + BONUS_TICKS);
		
		if (singleton != null) return true;

		var go = new GameObject("uLinkTargetFrameRateFix");
		go.AddComponent<uLinkTargetFrameRateFix>();
		go.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector | HideFlags.NotEditable;

		return true;
	}
Ejemplo n.º 8
0
	public static void SetTargetFrameRate(int frameRate)
	{
		if (QualitySettings.vSyncCount != 0) return;

		UnityEngine.Application.targetFrameRate = -1;

		if (UnityEngine.Application.platform != RuntimePlatform.WindowsPlayer)
		{
			UnityEngine.Application.targetFrameRate = frameRate;
			return;
		}

		try // make sure there is no issues calling these two native Win32 APIs
		{
			timeGetTime();
			MsgWaitForMultipleObjectsEx(0, null, 0, 0, 0);
		}
		catch (Exception)
		{
			UnityEngine.Application.targetFrameRate = frameRate;
			return;
		}

		if (frameRate == 0 || frameRate == -1)
		{
			if (singleton != null)
			{
				DestroyImmediate(singleton);
				singleton = null;
			}

			targetDeltaTicks = 0;
			return;
		}

		targetDeltaTicks = Mathf.RoundToInt(1000f / frameRate + BONUS_TICKS);
		
		if (singleton != null) return;

		var go = new GameObject("uLinkTargetFrameRateFix", typeof(uLinkTargetFrameRateFix));
		go.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector | HideFlags.NotEditable | HideFlags.DontSave;
	}