Пример #1
0
 void OnDestroy()
 {
     if (_instance == this)
     {
         _instance = null;
     }
 }
Пример #2
0
    static GPUProfiler _instance;     // Singleton

    void Awake()
    {
        if (Application.isPlaying)
        {
            if (_instance == null)
            {
                _instance = this;
                GameObject.DontDestroyOnLoad(this.gameObject);
            }
            else if (_instance != this)
            {
                GameObject.DestroyImmediate(this.gameObject);
                return;
            }
        }

        if (!Application.isPlaying)
        {
            if (this.font == null)
            {
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7
#else
                this.font = Font.CreateDynamicFontFromOSFont("Arial", 16);
                if (this.font == null)
                {
                    this.font = Font.CreateDynamicFontFromOSFont("Arial Bold", 16);
                }
#endif
            }
            if (this.fontMaterial == null || this.fontMaterial.shader == null)
            {
                Shader shader = Shader.Find("UI/GPUProfiler");
                if (shader != null)
                {
                    this.fontMaterial = new Material(shader);
                }
            }
        }

        string deviceModel = SystemInfo.deviceModel;
        if (deviceModel != null)
        {
            switch (deviceModel)
            {
            case "samsung SCV31":
                _deviceModel = DeviceModel.SCV31;
                break;

            case "samsung SCV33":
                _deviceModel = DeviceModel.SCV33;
                break;
            }
        }

        _UpdateLevel();
    }