示例#1
0
 public void OnPreStart()
 {
     Debug.Log("OnPreStart");
     _identity = GetComponent <SmartNetIdentity>();
     Debug.Assert(_identity != null);
     _renderer = GetComponent <Renderer>();
 }
        private static void TryAssignNewId(SmartNetIdentity identity)
        {
            Init();

            if (IdentityLibrary.Get(identity.AssetId) != identity)
            {
                AssignAssetId(identity, IdentityLibrary.GetNextPrefabId());
            }
        }
        private static void AssignAssetId(SmartNetIdentity identity, uint id)
        {
            var assetIdField = typeof(SmartNetIdentity).GetField("assetId", BindingFlags.NonPublic | BindingFlags.Instance);

            if (assetIdField == null)
            {
                Debug.LogError($"AssignData failed to locate 'assetId' field on {typeof(SmartNetIdentity).Name}");
                return;
            }

            assetIdField.SetValue(identity, id);
        }
        public static bool Remove(SmartNetIdentity identity)
        {
            Init();

            if (identity == null)
            {
                return(false);
            }

            IdentityLibrary.RemoveNullReferences();

            if (IdentityLibrary.Remove(identity))
            {
                UnityEditor.EditorUtility.SetDirty(IdentityLibrary.Ins);
                return(true);
            }

            return(false);
        }