예제 #1
0
        /// <summary>
        /// Creates an instance of a LoadManager. This can be done instead of having one precreated in the scene.
        /// </summary>
        /// <param name="secondsAllowedPerFrame">The amount of time the loader will execute before yield to a new frame.</param>
        /// <param name="webglMemoryThresholdForYield">Amount of memory System.GC.GetTotalMemory() can get to before yield to a new frame.</param>
        /// <param name="verboseLogging">Verbose print out the timing of each loaded object.</param>
        public static void CreateManager(
            float secondsAllowedPerFrame,
            int webglMemoryThresholdForYield = DEFAULT_WEBGL_MEMORY_THRESHOLD,
            bool verboseLogging = false)
        {
            if (_instance != null)
            {
                LogWarningFormat(
                    "{0} already exists, called to {1} will be ignored!",
                    typeof(LoadManager),
                    System.Reflection.MethodBase.GetCurrentMethod().Name);

                return;
            }

            LoadManager newLoad = (new GameObject(CREATED_NAME)).AddComponent <LoadManager>();

            newLoad.secondsAllowedPerFrame  = secondsAllowedPerFrame;
            newLoad.memoryThresholdForYield = webglMemoryThresholdForYield;
            newLoad.verboseLogging          = verboseLogging;
        }
예제 #2
0
        private void Awake()
        {
            if (_instance != null)
            {
                LogErrorFormat(
                    "Only one {1} allowed in the scene at a time!",
                    typeof(LoadManager));

                return;
            }

            _instance = this;

#if UNITY_WEBGL
            if (!Application.isEditor && !_webglInitialized)
            {
                JSInitialize();
                _webglInitialized = true;
            }
#endif
        }