private static Creator _CreateDefaultCreator(GameObject prefab, NetworkView parent, NetworkView[] children)
        {
            if (children != null && children.Length != 0)
            {
                Log.Info(NetworkLogFlags.Instantiate, "Setting up parent-child relationships in prefab '", prefab.GetName(), "' because it has multiple NetworkViews");

                parent.SetChildren(children);
            }
            else
            {
                parent._parent = null;                 // ensure it is null, because Unity 5.x (or later) might assign a "null object" which is not technically null.
            }

            // we assume the prefab isn't in the scene, otherwise it could be a child and strange things could happen.
            parent.prefabRoot = prefab.transform.root.gameObject;

            return(delegate(string prefabName, NetworkInstantiateArgs args, NetworkMessageInfo info)
            {
                Profiler.BeginSample("Instantiate: " + prefabName);
                var networkView = NetworkInstantiatorUtility.Instantiate(parent, args);
                Profiler.EndSample();

                Profiler.BeginSample(NetworkUnity.EVENT_INSTANTIATE);
                NetworkInstantiatorUtility.BroadcastOnNetworkInstantiate(networkView, info);
                Profiler.EndSample();

                return networkView;
            });
        }
        /// <summary>
        /// Creates the default <see cref="Creator"/> for the prefab and returns it.
        /// </summary>
        /// <param name="prefab">The prefab that you want to create a creator for.</param>
        /// <returns>The creator method.</returns>
        public static Creator CreateDefaultCreator(GameObject prefab)
        {
            var views = NetworkInstantiatorUtility.GetComponentsInChildren <NetworkView>(prefab.transform);

            if (views.Count == 0)
            {
                Log.Error(NetworkLogFlags.Instantiate, "Prefab '", prefab.GetName(), "' must at least have one NetworkView");
                return(null);
            }

            return(_CreateDefaultCreator(prefab, views));
        }
        /// <summary>
        /// Registers all prefabs in the asset bundle that does have a NetworkView component.
        /// This makes sure they can be instantiated later with
        /// <see cref="O:uLink.Network.Instantiate">uLink.Network.Instantiate</see>
        /// </summary>
        /// <param name="assetBundle">The asset bundle that you want to register its prefabs.</param>
        /// <param name="replaceIfExists">if <c>true</c> then prefabs with the same name will be replaced by the new ones in the asset bundle.</param>
        /// <remarks>
        /// This is a convenience method that calls <see cref="O:uLink.NetworkInstantiator.AddPrefab"/>
        /// for all prefabs in the asset bundle that has a network view component.
        /// <para>
        /// It is common for developers to minimize the download time for the Unity game at startup by putting
        /// some prefabs in asset bundles and then download the asset bundles when needed in the game.
        /// We recommend writing code that downloads the asset bundle, loads the prefabs, registers them with this method,
        /// and finally makes the calls to <see cref="O:uLink.Network.Instantiate">uLink.Network.Instantiate</see>.
        /// If it is an authoritative server the call to <see cref="O:uLink.Network.Instantiate">uLink.Network.Instantiate</see>
        /// has to be done on the server.
        /// </para>
        /// </remarks>
        public static void AddAssetBundle(AssetBundle assetBundle, bool replaceIfExists)
        {
#if UNITY_4
            var prefabs = assetBundle.LoadAll(typeof(GameObject)) as GameObject[];
#else
            var prefabs = assetBundle.LoadAllAssets <GameObject>();
#endif

            foreach (var prefab in prefabs)
            {
                var views = NetworkInstantiatorUtility.GetComponentsInChildren <NetworkView>(prefab.transform);
                if (views.Count != 0)
                {
                    Add(prefab.GetName(), _CreateDefault(prefab, views), replaceIfExists);
                }
            }
        }