Beispiel #1
0
    void Update()
    {
        if (_FpsGUIText == null || _BulletNumGUIText == null)
        {
            return;
        }

        _Frame++;
        float time = Time.realtimeSinceStartup - _LastUpdateTime;

        if (INTERVAL_SEC <= time)
        {
            // Count FPS
            float frameRate = _Frame / time;
            _FpsGUIText.text = "FPS : " + ((int)frameRate).ToString();
            _LastUpdateTime  = Time.realtimeSinceStartup;
            _Frame           = 0;

            // Count Bullet Num
            if (objectPool == null)
            {
                objectPool = FindObjectOfType <UbhObjectPool>();
            }
            if (objectPool != null)
            {
                int bulletNum = objectPool.GetActivePooledObjectCount();
                _BulletNumGUIText.text = "Bullet Num : " + bulletNum.ToString();
            }
        }
    }
Beispiel #2
0
    IEnumerator activeRocket()
    {
        isShoot = true;
        rocket.SetActive(true);
        UbhObjectPool bullet = FindObjectOfType <UbhObjectPool>();

        Destroy(bullet.gameObject);
        yield return(new WaitForSeconds(1.5f));

        rocket.SetActive(false);
        isShoot = false;
    }
    private void DrawProperties()
    {
        UbhObjectPool obj = target as UbhObjectPool;

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Release All Bullet"))
        {
            if (Application.isPlaying && obj.gameObject.activeInHierarchy)
            {
                UbhObjectPool.instance.ReleaseAllBullet();
            }
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        DrawDefaultInspector();
    }