void Update() { if (!isConnect) { return; } if (socket.Poll(10, SelectMode.SelectRead) && socket.Available == 0) { SuperDebug.Log("Disconnect!"); isConnect = false; return; } if (isReceivingHead) { ReceiveHead(); } else { ReceiveBody(); } }
public void Init(string _path, Action <byte[]> _callBack) { SuperDebug.Log("加载代码文件:" + _path); callBack = _callBack; StartCoroutine(LoadDll(_path)); }
public static void PrintLog() { if (Instance.needClearObjs) { foreach (KeyValuePair <string, int> pair in Instance.dic) { SuperDebug.Log("SuperRaycast key:" + pair.Key + " value:" + pair.Value); } } }
public static void PrintLog() { if (SuperGraphicRaycastScript.Instance.isOpen != 1) { foreach (KeyValuePair <string, int> pair in dic) { SuperDebug.Log("SuperGraphicRaycast key:" + pair.Key + " value:" + pair.Value); } } }
public static void Start() { GameObject go = Selection.activeGameObject; GameObject prefab = GameObject.Instantiate(go); LightmapData[] datas = LightmapSettings.lightmaps; Renderer[] renderers = go.GetComponentsInChildren <Renderer>(); foreach (Renderer renderer in renderers) { if (renderer.lightmapIndex != -1) { GameObject tg = PublicTools.FindChild(prefab, renderer.gameObject.name); LightmapGameObject ll = tg.AddComponent <LightmapGameObject>(); ll.lightmapIndex = renderer.lightmapIndex; ll.lightmapScaleOffset = renderer.lightmapScaleOffset; } } Scene scene = prefab.AddComponent <Scene>(); scene.farTextures = new Texture2D[datas.Length]; scene.nearTextures = new Texture2D[datas.Length]; for (int i = 0; i < datas.Length; i++) { scene.farTextures[i] = datas[i].lightmapFar; scene.nearTextures[i] = datas[i].lightmapNear; } scene.fieldOfView = Camera.main.fieldOfView; scene.ambientLight = RenderSettings.ambientLight; scene.ambientIntensity = RenderSettings.ambientIntensity; scene.fog = RenderSettings.fog; scene.fogColor = RenderSettings.fogColor; scene.fogStartDistance = RenderSettings.fogStartDistance; scene.fogEndDistance = RenderSettings.fogEndDistance; string path = "Assets/Arts/map/" + go.name + ".prefab"; PrefabUtility.CreatePrefab(path, prefab); GameObject.DestroyImmediate(prefab); AssetBundleTools.SetAssetBundleName(path, go.name); SuperDebug.Log("场景Prefab构造完成!"); }
public static void SetOpen(bool _b) { SuperDebug.Log("SetOpen: " + _b); m_isOpen = m_isOpen + (_b ? 1 : -1); if (m_isOpen > 1) { SuperDebug.LogError("SuperGraphicRaycast.SetOpen error!"); } }
IEnumerator webCam() { yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam)); if (Application.HasUserAuthorization(UserAuthorization.WebCam)) { WebCamDevice[] devices = WebCamTexture.devices; if (devices.Length > 0) { string deviceName = devices[0].name; WebCamTexture tmpWebCamTexture = new WebCamTexture(deviceName, Screen.height / 2, Screen.width / 2, 12); tmpWebCamTexture.Play(); while (tmpWebCamTexture.width < 100) { yield return(null); } webCamTexture = tmpWebCamTexture; // SuperDebug.Log("Screen.width:" + Screen.width + " Screen.height:" + Screen.height); // // SuperDebug.Log("canvasX:" + (ri.canvas.transform as RectTransform).sizeDelta.x + " canvasY:" + (ri.canvas.transform as RectTransform).sizeDelta.y); // // SuperDebug.Log("webCamTexture.width:" + webCamTexture.width + " webCamTexture.height:" + webCamTexture.height); // // SuperDebug.Log("webCamTexture.requestedWidth:" + webCamTexture.requestedWidth + " webCamTexture.requestedHeight:" + webCamTexture.requestedHeight); // SuperDebug.Log("webCamTexture.videoRotationAngle:" + webCamTexture.videoRotationAngle); SuperDebug.Log("webCamTexture.videoVerticallyMirrored:" + webCamTexture.videoVerticallyMirrored); rotationFix = webCamTexture.videoVerticallyMirrored ? -1 : 1; ri.transform.localScale = new Vector3(1, rotationFix, 1); ri.texture = webCamTexture; if ((float)webCamTexture.height / webCamTexture.width > (ri.canvas.transform as RectTransform).sizeDelta.x / (ri.canvas.transform as RectTransform).sizeDelta.y) { ri.rectTransform.sizeDelta = new Vector2((ri.canvas.transform as RectTransform).sizeDelta.y, (ri.canvas.transform as RectTransform).sizeDelta.y * webCamTexture.height / webCamTexture.width); } else { ri.rectTransform.sizeDelta = new Vector2((ri.canvas.transform as RectTransform).sizeDelta.x * webCamTexture.width / webCamTexture.height, (ri.canvas.transform as RectTransform).sizeDelta.x); } // SuperDebug.Log("ri.rectTransform.sizeDelta:" + ri.rectTransform.sizeDelta); } } }
public void Init() { GameObject tmpGo = PublicTools.FindChildForce(gameObject, CENTER_BONE_NAME); if (tmpGo != null) { centerBone = tmpGo.transform; } else { SuperDebug.Log("HeroController can not find " + CENTER_BONE_NAME + ". GameObject name:" + gameObject.name); } animators = gameObject.GetComponentsInChildren <Animator>(); for (int i = 0; i < animators.Length; i++) { if (animators[i].runtimeAnimatorController != null) { AnimatorFactory.Instance.AddUseNum(animators[i].runtimeAnimatorController.name); } } bodyMaterial = body.GetComponent <Renderer>().material; if (horse != null) { horseMaterial = horse.GetComponent <Renderer>().material; } if (wing != null) { wingMaterial = wing.GetComponent <Renderer>().material; } if (mainHandWeapon != null) { mainHandWeaponMaterial = mainHandWeapon.GetComponent <Renderer>().material; } if (offHandWeapon != null) { offHandWeaponMaterial = offHandWeapon.GetComponent <Renderer>().material; } SetPartIndex(2); SetWeaponVisible(true); AddShadow(); SetOutlineToggle(OutlineOpen == 1); }
private void GetAssemblyUpdated(bool _result) { if (_result) { SuperDebug.Log("找到了新的代码文件!!!"); } else { SuperDebug.Log("没有找到新的代码文件!!!"); } Application.LoadLevel("main"); }
private void GetAssemblyUpdated(bool _result) { if (_result) { SuperDebug.Log("找到了新的代码文件!!!"); } else { SuperDebug.Log("没有找到新的代码文件!!!"); } SceneManager.LoadScene(sceneName); }
private IEnumerator LoadCorotine(string _path, bool _isRemote, Action <WWW> _callBack) { string finalPath; if (!_isRemote) { if (fixUrlDelegate == null) { finalPath = path + _path; } else { bool b = fixUrlDelegate(ref _path); if (b) { finalPath = _path; } else { finalPath = path + _path; } } } else { finalPath = _path; } WWW www = new WWW(finalPath); yield return(www); // SuperDebug.Log ("资源加载成功:" + _path); if (www.error != null) { SuperDebug.Log("WWW download had an error:" + www.error + " finalPath:" + finalPath); // throw new Exception ("WWW download had an error:" + www.error); } Action callBack = delegate() { _callBack(www); www.Dispose(); }; callBackList.Add(callBack); }
public static void SetIsOpen(bool _isOpen, string _str) { Instance.m_isOpen = Instance.m_isOpen + (_isOpen ? 1 : -1); if (Instance.m_isOpen == 0) { if (!Instance.isProcessingUpdate) { Instance.objs.Clear(); } else { Instance.needClearObjs = true; } } else if (Instance.m_isOpen > 1) { PrintLog(); SuperDebug.Log("SuperRaycast error!!!!!!!!!!!!!"); } if (Instance.dic.ContainsKey(_str)) { if (_isOpen) { Instance.dic[_str]++; } else { Instance.dic[_str]--; } if (Instance.dic[_str] == 0) { Instance.dic.Remove(_str); } } else { if (_isOpen) { Instance.dic.Add(_str, 1); } else { Instance.dic.Add(_str, -1); } } }
private void LoadUpdateXMLOK(Dictionary <string, UpdateFileInfo> _dic, int _remoteVersion, Func <string, string> _fixFun, Action _callBack) { int loadNum = _dic.Count; foreach (KeyValuePair <string, UpdateFileInfo> pair in _dic) { string path = pair.Key; UpdateFileInfo info = pair.Value; string url = _fixFun(info.path + path); Action <WWW> callBack = delegate(WWW obj) { if (obj.error != null) { SuperDebug.Log("文件热更新失败 文件名:" + obj.url); return; } UInt32 crc = CRC32.Compute(obj.bytes); if (crc != info.crc) { SuperDebug.Log("文件热更新CRC比对错误 文件名:" + obj.url); return; } SystemIO.SaveFile(Application.persistentDataPath + "/" + path, obj.bytes); if (data.dic.ContainsKey(path)) { data.dic[path] = info.version; } else { data.dic.Add(path, info.version); } loadNum--; if (loadNum == 0) { UpdateOver(_remoteVersion, _callBack); } }; WWWManager.Instance.LoadRemote(url, callBack); } }
public static IPAddress GetIPAddress(IPAddress ip) { #if UNITY_IPHONE bool isIPV4Format = ip.AddressFamily == AddressFamily.InterNetwork; bool isIPV6Environment = IsIPV6(); if (isIPV4Format && isIPV6Environment) { string ipv6 = IPV6Access.ConvertIPv4ToIPv6(ip.ToString()); SuperDebug.Log(DebugPrefix.Network, string.Format("convert ipv4={0} ipv6={1}", ip, ipv6)); ip = IPAddress.Parse(ipv6); } #endif return(ip); }
IEnumerator LoadDll(string _path) { WWW www = new WWW(_path); yield return(www); loadOK = true; if (string.IsNullOrEmpty(www.error)) { bytes = www.bytes; } else { SuperDebug.Log(www.error); } }
public void Init(Action _callBack) { Action <AssetBundle> del = delegate(AssetBundle obj) { if (assetBundle != null) { assetBundle = obj; } else { SuperDebug.Log("ShaderManager init fail!"); } _callBack(); }; AssetBundleManager.Instance.Load(assetBundleName, del); }
IEnumerator LoadDll(string _path, Action <byte[]> _callBack) { WWW www = new WWW(_path); yield return(www); if (string.IsNullOrEmpty(www.error)) { _callBack(www.bytes); } else { SuperDebug.Log(www.error); _callBack(null); } }
private void GetAssemblyUpdated(bool _result) { if (_result) { SuperDebug.Log("找到了新的代码文件!!!"); Application.LoadLevel("main"); } else { #if PLATFORM_PC AssemblyManager.Instance.Init("file:///" + Application.streamingAssetsPath + "/" + ASSEMBLY_FILE_NAME, GetAssemblyOriginal); #else AssemblyManager.Instance.Init(Application.streamingAssetsPath + "/" + ASSEMBLY_FILE_NAME, GetAssemblyOriginal); #endif } }
/* * 主动断开连接 */ public void Disconnect() { connected_before_ = false; if (IsConnected()) { SuperDebug.Log(DebugPrefix.Network, "disconnect to " + host_ + ":" + port_); /* 多线程可能让socket_为空 */ if (socket_ != null) { socket_.Close(); } socket_ = null; timeout_event_.Set(); } }
public void Init(int _localVersion, int _remoteVersion, Func <int, string> _fixFun, Func <string, string> _fixFun2, Action _callBack, Action <string> _setTextCallBack, Action <float> _setPercentCallBack, int _updateWarningSize, Action <string, Action> _showWarningCallBack) { if (File.Exists(Application.persistentDataPath + "/" + FILE_NAME)) { data = VersionData.LoadFromFile(Application.persistentDataPath + "/" + FILE_NAME); if (_localVersion > data.version) //说明残留的version.dat是老版本的 必须立即清除掉 { SuperDebug.Log("发现残留的version.dat 删除掉!"); data = new VersionData(); data.version = _localVersion; VersionData.SaveToFile(Application.persistentDataPath + "/" + FILE_NAME, data); } } else { SuperDebug.Log("这是第一次进游戏 生成新的version.dat"); data = new VersionData(); data.version = _localVersion; VersionData.SaveToFile(Application.persistentDataPath + "/" + FILE_NAME, data); } SuperDebug.Log("客户端资源版本号:" + data.version + " 服务器资源版本号:" + _remoteVersion); if (data.version < _remoteVersion) { _setTextCallBack("读取热更新列表"); Dictionary <string, UpdateFileInfo> dic = new Dictionary <string, UpdateFileInfo>(); LoadUpdateXML(0, dic, _remoteVersion, _remoteVersion, _fixFun, _fixFun2, _callBack, _setTextCallBack, _setPercentCallBack, _updateWarningSize, _showWarningCallBack); } else { _callBack(); } }
// Use this for initialization void Awake() { SuperDebug.Log("aaaa:" + gameObject.name); if (material == null) { SuperDebug.LogError("CameraEffect has not material!"); } rt = new RenderTexture(Screen.width, Screen.height, 24); Camera camera = gameObject.GetComponent <Camera>(); camera.cullingMask = 0; camera.clearFlags = CameraClearFlags.Nothing; materialReal = Material.Instantiate <Material>(material); }
public static void SetIsOpen(bool _isOpen, string _str) { Instance.isOpen = Instance.isOpen + (_isOpen ? 1 : -1); if (Instance.isOpen == 0) { if (!Instance.isProcessingUpdate) { Instance.objs.Clear(); } else { Instance.needClearObjs = true; } } else if (Instance.isOpen > 1) { SuperDebug.Log("SuperRaycast error!!!!!!!!!!!!!"); } }
/* * 循环读取数据的线程, 逐个处理包 * 目前读取在主线程中,而不在网络线程中 */ private void ClientConsumerThreadHandler() { SuperDebug.Log(DebugPrefix.Network, "clientConsumer thread start."); while (IsConnected() || 0 < recv_queue_.Count) { // 等待的毫秒数,为 Timeout.Infinite,表示无限期等待。 NetPacket packet = Recv(Timeout.Infinite); if (packet != null) { SuperDebug.Log(DebugPrefix.Network, "clientConsumer recv: CmdId=" + packet.GetCmdId()); doCmd_callback_(packet); } else { SuperDebug.Warning(DebugPrefix.Network, "packet = null in clientConsumerThreadHandler"); } } SuperDebug.Log(DebugPrefix.Network, "clientConsumer thread stop."); }
// Use this for initialization void Start() { SuperScrollRect scrollRect = gameObject.AddComponent <SuperScrollRect>(); scrollRect.content = childTransform; scrollRect.horizontal = true; scrollRect.vertical = true; scrollRect.movementType = ScrollRect.MovementType.Clamped; SuperFunction.Instance.RemoveEventListener(SuperScrollRect.eventDispatcher, SuperScrollRect.CLOSE_MOVE, scrollRect.CloseMove); SuperFunction.Instance.RemoveEventListener(SuperScrollRect.eventDispatcher, SuperScrollRect.OPEN_MOVE, scrollRect.OpenMove); containerHalfRect = (transform as RectTransform).rect.size / 2; SuperFunction.Instance.AddEventListener(ScreenScale.Instance.gameObject, ScreenScale.SCALE_CHANGE, ScaleChange); childWidth = childTransform.rect.width; childHeight = childTransform.rect.height; if (minScale == 0) { float widthScale = containerHalfRect.x * 2 / childWidth * 1.001f; float heightScale = containerHalfRect.y * 2 / childHeight * 1.001f; minScale = Mathf.Max(widthScale, heightScale); } if (maxScale == 0) { maxScale = 1; } SuperDebug.Log("SuperScaleScrollRect minScale:" + minScale + " maxScale:" + maxScale); }
/// <summary> /// _str 传 类名-锁屏/解锁功能名 /// </summary> /// <param name="_isOpen"></param> /// <param name="_str"></param> public static void SetIsOpen(bool _isOpen, string _str) { SuperDebug.Log("-->> _isOpen: " + _isOpen + " , _str: " + _str); SuperGraphicRaycastScript.Instance.isOpen = SuperGraphicRaycastScript.Instance.isOpen + (_isOpen ? 1 : -1); if (dic.ContainsKey(_str)) { if (_isOpen) { dic[_str]++; } else { dic[_str]--; } if (dic[_str] == 0) { dic.Remove(_str); } } else { if (_isOpen) { dic.Add(_str, 1); } else { dic.Add(_str, -1); } } if (SuperGraphicRaycastScript.Instance.isOpen > 1) { PrintLog(); SuperDebug.LogError("SuperGraphicRaycast.SetOpen error!"); } }
public void Init(int _localVersion, int _remoteVersion, Func <int, string> _fixFun, Func <string, string> _fixFun2, Action _callBack) { if (File.Exists(Application.persistentDataPath + "/" + FILE_NAME)) { data = SystemIO.LoadSerializeFile <VersionData>(Application.persistentDataPath + "/" + FILE_NAME); if (_localVersion > data.version) //说明残留的version.dat是老版本的 必须立即清除掉 { SuperDebug.Log("发现残留的version.dat 删除掉!"); data = new VersionData(); data.version = _localVersion; SystemIO.SaveSerializeFile(Application.persistentDataPath + "/" + FILE_NAME, data); } } else { data = new VersionData(); data.version = _localVersion; SystemIO.SaveSerializeFile(Application.persistentDataPath + "/" + FILE_NAME, data); } if (data.version < _remoteVersion) { Dictionary <string, UpdateFileInfo> dic = new Dictionary <string, UpdateFileInfo>(); LoadUpdateXML(dic, _remoteVersion, _remoteVersion, _fixFun, _fixFun2, _callBack); } else { _callBack(); } }
private void GetAssetBundle(ref int _loadNum, AssetBundle _assetBundle) { _loadNum--; if (_loadNum == 0) { if (AssetManager.LOADASYNC) { AssetManager.Instance.script.Load <T>(name, _assetBundle, LoadOver); } else { T asset = null; try{ asset = _assetBundle.LoadAsset <T>(name); }catch (Exception e) { SuperDebug.Log("Asset加载错误:" + e.Message); }finally{ LoadOver(asset); } } } }
/* * 循环接受数据的线程,将收到的packet写入队列 */ private void ClientProducerThreadHandler() { SuperDebug.Log(DebugPrefix.Network, "clientProducer thread start."); while (IsConnected()) { try { List <NetPacket> list = RecvPacketList(); //MiLog.Log("recv " + list.Count + " packet"); if (null != list && 0 != list.Count) { foreach (NetPacket packet in list) { #if NG_HSOD_DEBUG //Thread.Sleep(100); #endif lock (recv_queue_) { recv_queue_.Enqueue(packet); } } timeout_event_.Set(); } // 发送心跳包 KeepAlive(); } catch (SystemException e) { SuperDebug.Error(DebugPrefix.Network, e.ToString()); } } // 断开连接 Disconnect(); SuperDebug.Log(DebugPrefix.Network, "clientProducer thread stop."); }
private void LoadUpdateXML(int _allFileSize, Dictionary <string, UpdateFileInfo> _dic, int _remoteVersion, int _version, Func <int, string> _fixFun, Func <string, string> _fixFun2, Action _callBack, Action <string> _setTextCallBack, Action <float> _setPercentCallBack, int _updateWarningSize, Action <string, Action> _showWarningCallBack) { if (_version > data.version) { string url = _fixFun(_version); Action <WWW> callBack = delegate(WWW obj) { if (obj.error != null) { _setTextCallBack("热更新列表加载失败"); SuperDebug.Log("文件热更新失败 文件名:" + obj.url); return; } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(PublicTools.XmlFix(obj.text)); XmlNodeList hhh = xmlDoc.ChildNodes[0].ChildNodes; foreach (XmlNode node in hhh) { string nodeUrl = node.InnerText; if (!_dic.ContainsKey(nodeUrl)) { int fileSize = int.Parse(node.Attributes["size"].Value); if (fileSize == -1) { if (data.dic.ContainsKey(nodeUrl)) { data.dic.Remove(nodeUrl); } } else { _allFileSize += fileSize; UpdateFileInfo fileInfo = new UpdateFileInfo(); fileInfo.version = _version; fileInfo.size = fileSize; fileInfo.path = node.Attributes["path"].Value; fileInfo.crc = Convert.ToUInt32(node.Attributes["crc"].Value, 16); _dic.Add(nodeUrl, fileInfo); } } } LoadUpdateXML(_allFileSize, _dic, _remoteVersion, _version - 1, _fixFun, _fixFun2, _callBack, _setTextCallBack, _setPercentCallBack, _updateWarningSize, _showWarningCallBack); }; WWWManager.Instance.LoadRemote(url, callBack); } else { if (_allFileSize >= _updateWarningSize && _showWarningCallBack != null) { Action callBack = delegate() { LoadUpdateXMLOK(_dic, _remoteVersion, _fixFun2, _callBack, _setTextCallBack, _setPercentCallBack, _allFileSize); }; float tempnum = (float)Math.Round(((float)_allFileSize) / 1024 / 1024, 2); string msg = "需要更新" + tempnum.ToString() + "MB大小的新文件,确认更新吗?"; _showWarningCallBack(msg, callBack); } else { LoadUpdateXMLOK(_dic, _remoteVersion, _fixFun2, _callBack, _setTextCallBack, _setPercentCallBack, _allFileSize); } } }
private static void PrintLog(string _str) { SuperDebug.Log(_str); }