示例#1
0
            /// <summary>
            /// Finishes the specified item if there was an explicit error or request is done.
            /// Returns whether finish process was done.
            /// </summary>
            private bool FinishRequest(NetkoItem item)
            {
                if (item.RequestInfo.IsFinished)
                {
                    // Request count management.
                    CurrentProcessCount--;

                    // OnFinished callack.
                    item.DispatchEvent(2);

                    // If item wasn't flagged for retry (IsProcessing == true), we should terminate it.
                    if (item.RequestInfo.IsProcessing)
                    {
                        item.Terminate();
                    }
                    // Flagged retry
                    else
                    {
                        //If attempted termination after calling retry, this is an invalid action.
                        if (item.RequestInfo.IsTerminated)
                        {
                            RenLog.LogWarning(
                                "Netko.Updater.FinishRequest - You should not call item.Terminate() directly after " +
                                "retrying! Forcing retry..."
                                );
                            // Force retry.
                            item.Retry();
                        }
                    }
                    return(true);
                }
                return(false);
            }
示例#2
0
        /// <summary>
        /// Creates prefabs for all views in specified config if not already exists.
        /// </summary>
        public static void CreatePrefabs(MVC mvc, MvcConfig config)
        {
            if (mvc.ViewParent == null)
            {
                RenLog.LogWarning("CreatePrefab - You must assign the ViewParent property on MVC object first.");
                return;
            }

            for (int i = 0; i < config.Views.Count; i++)
            {
                Create(mvc, config.Views[i]);
            }
        }
示例#3
0
        /// <summary>
        /// Creates a new MVC view prefab for specified view.
        /// </summary>
        private static void Create(MVC mvc, MvcConfig.View view)
        {
            // If prefab file already exists, return
            if (File.Exists(view.GetResourcePath(true)))
            {
                return;
            }

            // Create a new object to make prefab.
            GameObject prefab = new GameObject(view.GetViewName());

            InitializeTransform(prefab, mvc.ViewParent.transform);

            // Create a child _Holder object.
            GameObject child = new GameObject("Container");

            InitializeTransform(child, prefab.transform);

            // Attach the UIPanel component first, then WidgetContainer.
            // Even though MVC Views require them as a dependency, it doesn't really look nice with the
            // component order all mixed up.
            prefab.AddComponent <UIPanel>();
            prefab.AddComponent <UIWidgetContainer>();

            // Find view's type and attach a view component on it.
            Type type        = null;
            var  checkResult = MvcValidator.CheckTypeExists(view.GetViewName(), out type);

            if (checkResult != ValidationResult.Success || type == null)
            {
                RenLog.LogWarning(string.Format(
                                      "MvcPrefabMaker.Create - Failed to find type: {0}. Make sure the configuration is applied.",
                                      view.GetViewName()
                                      ));
                GameObject.DestroyImmediate(prefab);
                return;
            }
            prefab.AddComponent(type);

            // Get UIPanel
            var panel = prefab.GetComponent <UIPanel>();

            panel.clipping = UIDrawCall.Clipping.ConstrainButDontClip;
            panel.SetRect(0f, 0f, mvc.BaseResolution.x, mvc.BaseResolution.y);

            // Create prefab
            string path = "Assets/Resources/" + view.GetResourcePath(false) + ".prefab";

            PrefabUtility.CreatePrefab(path, prefab, ReplacePrefabOptions.ConnectToPrefab);
        }
示例#4
0
        /// <summary>
        /// Finalizes the awake process.
        /// </summary>
        void FinalizeAwake()
        {
            // No initialization, no MVC
            if (!isCoreInitialized)
            {
                RenLog.Log(LogLevel.Error, "MVC.FinalizeAwake - Core MVC components are not initialized!");
                Destroy(gameObject);
                return;
            }
            // View parent is not set.
            // If user really wants to MVC without the parent, ShowView should be called manually.
            if (ViewParent == null)
            {
                RenLog.LogWarning("MVC.FinalizeAwake - ViewParent property is null! " +
                                  "Call MVC.ShowView after setting the property.");
                return;
            }

            // Show first view, then we're finished :D
            if (InitialViewOnAwake && firstViewType != null)
            {
                ShowView(firstViewType);
            }
        }