Пример #1
0
    private NetworkView Create(ref CustomInstantiationArgs args, out IDMain instance)
    {
        NetworkView view3;

        if ((float.IsNaN(args.position.x) || float.IsNaN(args.position.y)) || float.IsNaN(args.position.z))
        {
            Debug.LogWarning("NetMainPrefab -> Create -  args.position = " + args.position);
            Debug.LogWarning("This means you're creating an object with a bad position!");
        }
        NetInstance instance2 = _currentNetInstance;

        try
        {
            _currentNetInstance = null;
            if (args.hasCustomInstantiator)
            {
                NetworkView networkView;
                instance = null;
                try
                {
                    instance = args.customInstantiate.CustomInstantiatePrefab(ref args);
                }
                catch (Exception exception)
                {
                    Debug.LogError(string.Format("Thrown Exception during custom instantiate via '{0}' with instantiation '{2}'\r\ndefault instantiation will now occur --  exception follows..\r\n{1}", args.customInstantiate, exception, this), this);
                    if (instance != null)
                    {
                        Object.Destroy(instance);
                    }
                    instance = null;
                }
                try
                {
                    networkView = instance.networkView;
                    if (networkView == null)
                    {
                        Debug.LogWarning(string.Format("The custom instantiator '{0}' with instantiation '{1}' did not return a idmain with a network view. so its being added", args.customInstantiate, this), this);
                        networkView = instance.gameObject.AddComponent <uLinkNetworkView>();
                    }
                }
                catch (Exception exception2)
                {
                    networkView = null;
                    Debug.LogError(string.Format("The custom instantiator '{0}' did not instantiate a IDMain with a networkview or something else with instantiation '{2}'.. \r\n {1}", args.customInstantiate, exception2, this), this);
                }
                if (networkView != null)
                {
                    return(networkView);
                }
            }
            NetworkView view2 = (NetworkView)NetworkInstantiatorUtility.Instantiate(args.prefabNetworkView, args.args);
            instance = view2.GetComponent <IDMain>();
            view3    = view2;
        }
        finally
        {
            _currentNetInstance = instance2;
        }
        return(view3);
    }
Пример #2
0
 protected virtual void StandardInitialization(bool didAppend, IDRemote appended, NetInstance instance, Facepunch.NetworkView view, ref uLink.NetworkMessageInfo info)
 {
     if (didAppend)
     {
         IssueLocallyAppended(appended, instance.idMain);
     }
     if (this.ShouldDoStandardInitialization(instance))
     {
         NetworkInstantiatorUtility.BroadcastOnNetworkInstantiate(view, "uLink_OnNetworkInstantiate", info);
     }
 }