void Update() { Plane[] planes = GeometryUtility.CalculateFrustumPlanes(renderCamera); if (!GeometryUtility.TestPlanesAABB(planes, GetBounds(bounds[0]))) //看不到中间那个了 { if (GeometryUtility.TestPlanesAABB(planes, GetBounds(bounds[1]))) //看得到右面那个 那我把中间那个移动到右面 把右面那个隐藏 { transform.position = transform.position + new Vector3(bounds[0].size.x, 0, 0); copy.SetActive(false); } else if (GeometryUtility.TestPlanesAABB(planes, GetBounds(bounds[2]))) //看得到左面那个 那我把中间那个移动到左面 把左面那个隐藏 { transform.position = transform.position - new Vector3(bounds[0].size.x, 0, 0); copy.SetActive(false); } else //左右都看不到了 怎么玩 { SuperDebug.LogError("See nothing!"); } } else //看得到中间那个 { bool getRight = GeometryUtility.TestPlanesAABB(planes, GetBounds(bounds[1])); bool getLeft = GeometryUtility.TestPlanesAABB(planes, GetBounds(bounds[2])); if (getRight && getLeft) { SuperDebug.LogError("See both left and right!"); } else if (getRight) //看得到右面那个 { if (!copy.activeSelf) { copy.transform.position = transform.position + new Vector3(bounds[0].size.x, 0, 0); copy.SetActive(true); } } else if (getLeft) //看得到左面那个 { if (!copy.activeSelf) { copy.transform.position = transform.position - new Vector3(bounds[0].size.x, 0, 0); copy.SetActive(true); } } else //左右都看不到 { if (copy.activeSelf) { copy.SetActive(false); } } } }
public void ModifyVertices(List <UIVertex> verts) { Text text = GetComponent <Text> (); if (text == null) { SuperDebug.LogWarning("LetterSpacing: Missing Text component"); return; } string[] lines = text.text.Split('\n'); Vector3 pos; float letterOffset = spacing * (float)text.fontSize / 100f; float alignmentFactor = 0; int glyphIdx = 0; switch (text.alignment) { case TextAnchor.LowerLeft: case TextAnchor.MiddleLeft: case TextAnchor.UpperLeft: alignmentFactor = 0f; break; case TextAnchor.LowerCenter: case TextAnchor.MiddleCenter: case TextAnchor.UpperCenter: alignmentFactor = 0.5f; break; case TextAnchor.LowerRight: case TextAnchor.MiddleRight: case TextAnchor.UpperRight: alignmentFactor = 1f; break; } for (int lineIdx = 0; lineIdx < lines.Length; lineIdx++) { string line = lines [lineIdx]; float lineOffset = (line.Length - 1) * letterOffset * alignmentFactor; for (int charIdx = 0; charIdx < line.Length; charIdx++) { int idx1 = glyphIdx * 6 + 0; int idx2 = glyphIdx * 6 + 1; int idx3 = glyphIdx * 6 + 2; int idx4 = glyphIdx * 6 + 3; int idx5 = glyphIdx * 6 + 4; int idx6 = glyphIdx * 6 + 5; // Check for truncated text (doesn't generate verts for all characters) if (idx4 > verts.Count - 1) { return; } UIVertex vert1 = verts [idx1]; UIVertex vert2 = verts [idx2]; UIVertex vert3 = verts [idx3]; UIVertex vert4 = verts [idx4]; UIVertex vert5 = verts [idx5]; UIVertex vert6 = verts [idx6]; pos = Vector3.right * (letterOffset * charIdx - lineOffset); vert1.position += pos; vert2.position += pos; vert3.position += pos; vert4.position += pos; vert5.position += pos; vert6.position += pos; verts [idx1] = vert1; verts [idx2] = vert2; verts [idx3] = vert3; verts [idx4] = vert4; verts [idx5] = vert5; verts [idx6] = vert6; glyphIdx++; } // Offset for carriage return character that still generates verts glyphIdx++; } }
/* * 同步方式接受多个消息 * 如果当前有可读消息,则立刻返回,否则超时等待设置的时间 */ private List <NetPacket> RecvPacketList() { // 检查连接状态 if (!IsConnected()) { SuperDebug.Warning(DebugPrefix.Network, "client is not connected, can not recv now."); return(null); } // 开始接受数据 List <NetPacket> list = new List <NetPacket>(); try { // 接受到缓存 byte[] recv_buf = new byte[ClientDefine.g_recv_buf_size - left_buf_len_]; SocketError error = new SocketError(); int recv_len = socket_.Receive(recv_buf, 0, recv_buf.Length, SocketFlags.None, out error); // 接受超时立刻返回 if (error == SocketError.TimedOut || error == SocketError.WouldBlock || error == SocketError.IOPending) { return(list); } // 如果接受数据长度为0,则表示连接出现异常,需要立刻使用回调函数通知使用方 if (error != SocketError.Success || 0 == recv_len) { SuperDebug.Warning(DebugPrefix.Network, "recv failed with recv_len=" + recv_len + ", error=" + error); socket_.Close(); socket_ = null; return(list); } // 合并上次剩余、本次收到的数据 byte[] total_buf = new byte[ClientDefine.g_recv_buf_size]; Array.Copy(left_buf_, 0, total_buf, 0, left_buf_len_); Array.Copy(recv_buf, 0, total_buf, left_buf_len_, recv_len); int total_len = recv_len + left_buf_len_; left_buf_len_ = 0; // 开始处理 int used = 0; // 一次可能recv多个packet,循环反序列化每个packet,并加入list while (used < total_len) { //缓存之前的有效数据 if (_tempPacket == null) { _tempPacket = new NetPacket(); } PacketStatus packet_status = _tempPacket.Deserialize(ref total_buf, ref used, total_len); if (PacketStatus.PACKET_CORRECT != packet_status) { // 存储残缺的数据 if (PacketStatus.PACKET_NOT_COMPLETE == packet_status) { left_buf_len_ = total_len - used; Array.Copy(total_buf, used, left_buf_, 0, left_buf_len_); } else { SuperDebug.Warning(DebugPrefix.Network, "deserialize packet failed. " + packet_status); } break; } else { list.Add(_tempPacket); _tempPacket = null; } } } catch (SystemException e) { if (IsConnected()) { SuperDebug.Error(DebugPrefix.Network, "recv failed: " + e); } } return(list); }
public void UnexceptedDisconnectCallback() { SuperDebug.Log(DebugPrefix.Network, "UnExceptedDisconnectCallback"); }
private static void CreateAssetBundleDat(AssetBundleManifest manifest, BuildAssetBundleOptions _buildOptions, BuildTarget _buildTarget) { if (manifest == null) { return; } string[] abs = manifest.GetAllAssetBundles(); AssetBundle[] aaaa = new AssetBundle[abs.Length]; try{ List <string> assetNames = new List <string> (); List <string> assetBundleNames = new List <string> (); Dictionary <string, List <string> > result = new Dictionary <string, List <string> > (); for (int i = 0; i < abs.Length; i++) { //AssetBundle ab = LoadAssetBundle("file:///" + Application.streamingAssetsPath + "/" + AssetBundleManager.path + abs[i]); AssetBundle ab = AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/" + AssetBundleManager.path + abs[i]); aaaa[i] = ab; string[] strs = ab.GetAllAssetNames(); for (int m = 0; m < strs.Length; m++) { string str = strs[m]; if (assetNames.Contains(str)) { SuperDebug.LogError("error!"); } else { assetNames.Add(str); assetBundleNames.Add(abs[i]); List <string> ll = new List <string>(); result.Add(str, ll); } } } for (int i = 0; i < assetNames.Count; i++) { string assetName = assetNames[i]; string abName = assetBundleNames[i]; List <string> list = result[assetName]; string[] strs = AssetDatabase.GetDependencies(assetName); for (int m = 0; m < strs.Length; m++) { string tmpAssetName = strs[m].ToLower(); if (tmpAssetName != assetName) { int index = assetNames.IndexOf(tmpAssetName); if (index != -1) { string assetBundleName = assetBundleNames[index]; if (assetBundleName != abName && !list.Contains(assetBundleName)) { list.Add(assetBundleName); } } } } } FileInfo fi = new FileInfo(Application.streamingAssetsPath + "/" + AssetManager.dataName); if (fi.Exists) { fi.Delete(); } FileStream fs = fi.Create(); BinaryWriter bw = new BinaryWriter(fs); AssetManagerDataFactory.SetData(bw, assetNames, assetBundleNames, result); fs.Flush(); bw.Close(); fs.Close(); fs.Dispose(); }catch (Exception e) { Debug.Log("error:" + e.Message); }finally{ foreach (AssetBundle aaa in aaaa) { aaa.Unload(true); } } }
private static void PrintLog(string _str) { SuperDebug.Log(_str); }
private void ConnectOK() { SuperDebug.Log("ConnectOK"); }
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); } } }
public void Start() { SuperDebug.Log(DebugPrefix.Network, "hello world"); }
public void Awake() { SuperDebug.LoadConfig(); }
public static void SetIsOpen(bool _isOpen, string _str) { if (_Instance == null) { //SuperDebug.Log("SuperRaycast _Instance is null! value:" + _isOpen + " str:" + _str + " " + _Instance); return; } //SuperDebug.Log("SuperRaycastReal value:" + _isOpen + " str:" + _str + " " + _Instance); _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) { SuperDebug.Log("SuperRaycast error!!!!!!!!!!!!!"); foreach (KeyValuePair <string, int> pair in _Instance.dic) { SuperDebug.Log("key:" + pair.Key + " value:" + pair.Value); } SuperDebug.LogError("3D SuperRaycast SetOpen 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 ReceiveBodyEnd(IAsyncResult _result) { int length = socket.EndReceive(_result); Debug.Log("ReceiveBodyEnd!" + length + " " + bodyLength); if (length == 0) { SuperDebug.LogError("Disconnect!!!"); } else if (length < bodyLength) { bodyLength = bodyLength - length; bodyOffset = bodyOffset + length; ReceiveBody(); } else { Debug.Log("all!" + length + " " + bodyLength); receiveStream.Position = 0; receiveStream.Write(bodyBuffer, 0, bodyOffset + length); receiveStream.Position = 0; BaseProto data = null; try{ data = reveiveFormatter.Deserialize(receiveStream) as BaseProto; }catch (Exception e) { Debug.Log(e.ToString()); } Debug.Log("receive:" + data.GetType().ToString()); switch (data.type) { case PROTO_TYPE.C2S: SuperDebug.LogError("error1!"); return; case PROTO_TYPE.S2C: BaseProto sendData = null; Action <BaseProto> tmpCallBack = nowCallBack; nowCallBack = null; Action callBack = delegate() { tmpCallBack(data); }; lock (receivePool){ receivePool.Add(callBack); } lock (sendPool){ if (!isWaittingForResponse) { SuperDebug.LogError("error6!"); return; } if (sendPool.Count > 0) { sendData = sendPool[0]; sendPool.RemoveAt(0); nowCallBack = callBackPool[0]; callBackPool.RemoveAt(0); } else { isWaittingForResponse = false; } } if (sendData != null) { SendDataReal(sendData); } break; default: Type protoType = data.GetType(); if (pushDic.ContainsKey(protoType)) { callBack = delegate() { pushDic[protoType](data); }; lock (receivePool){ receivePool.Add(callBack); } } else { SuperDebug.LogError("error669!"); } break; } ReceiveHead(); } }
/* * 建立连接 */ public bool Connect(string host, ushort port, int timeout_ms = 2000) //以毫秒为单位 { try { // 检查是否已经建立连接 if (IsConnected()) { SuperDebug.Warning(DebugPrefix.Network, "client is already connected to " + host_ + ":" + port_ + ", can not connect to other server now."); return(false); } // 赋值 host_ = host; port_ = port; timeout_ms_ = timeout_ms; // 根据host获取ip列表 IPAddress[] ip_list = Dns.GetHostAddresses(host_); if (0 == ip_list.Length) { SuperDebug.Warning(DebugPrefix.Network, "can not get any ip address from host " + host_); return(false); } // 尝试连接每个ip socket_ = null; _remoteEndPoint = null; for (int idx = 0; idx < ip_list.Length; idx++) { IPAddress ip_tmp = GetIPAddress(ip_list[idx]); SuperDebug.Log(DebugPrefix.Network, "try to connect to " + ip_tmp); IPEndPoint ipe = new IPEndPoint(ip_tmp, port_); Socket socket_tmp = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp); // 初始化socket属性 socket_tmp.NoDelay = true; socket_tmp.Blocking = true; socket_tmp.SendTimeout = timeout_ms_; socket_tmp.ReceiveTimeout = timeout_ms_; socket_tmp.ReceiveBufferSize = ClientDefine.g_recv_buf_size * 2; // 连接 timeout_event_.Reset(); socket_tmp.BeginConnect(ip_tmp, port_, new AsyncCallback(ConnectCallback), socket_tmp); // 超时等待连接建立 timeout_event_.WaitOne(timeout_ms, false); // 检验连接是否成功 if (socket_tmp.Connected) { socket_ = socket_tmp; _remoteEndPoint = ipe; SuperDebug.Log(DebugPrefix.Network, "socket_.ReceiveBufferSize= " + socket_.ReceiveBufferSize); break; } else { SuperDebug.Log(DebugPrefix.Network, "connect to " + ip_tmp + " timeout."); continue; } } // 检查是否成功连接 if (null == socket_) { SuperDebug.Warning(DebugPrefix.Network, "connect to " + host_ + ":" + port_ + " failed."); return(false); } else { SuperDebug.Log(DebugPrefix.Network, "connect to " + host_ + ":" + port_ + " succ."); SuperDebug.Log(DebugPrefix.Network, "_remoteEndPoint= " + _remoteEndPoint); } // 启动工作线程 StartClientThread(); // connected_before_ = true; } catch (System.Exception e) { SuperDebug.Error(DebugPrefix.Network, "connect to " + host + ":" + port + " meet exception " + e.ToString()); return(false); } return(true); }
private void LoadUpdateXML(Dictionary <string, UpdateFileInfo> _dic, int _remoteVersion, int _version, Func <int, string> _fixFun, Func <string, string> _fixFun2, Action _callBack) { if (_version > data.version) { string url = _fixFun(_version); // url = @"http://192.168.40.240/update_and/versions/update_101_and_facebook.xml"; Action <WWW> callBack = delegate(WWW obj) { if (obj.error != null) { 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 { 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(_dic, _remoteVersion, _version - 1, _fixFun, _fixFun2, _callBack); }; WWWManager.Instance.LoadRemote(url, callBack); } else { LoadUpdateXMLOK(_dic, _remoteVersion, _fixFun2, _callBack); } }
private void LoginOver(LoginResultProto _result) { SuperDebug.Log("result:" + _result.result); }
private void LoadUpdateXMLOK(Dictionary <string, UpdateFileInfo> _dic, int _remoteVersion, Func <string, string> _fixFun, Action _callBack, Action <string> _setTextCallBack, Action <float> _setPercentCallBack, int _allFileSize) { int loadNum = _dic.Count; int loadSize = 0; 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) { _setTextCallBack("文件热更新失败 文件名:" + obj.url); SuperDebug.Log("文件热更新失败 文件名:" + obj.url); return; } UInt32 crc = CRC32.Compute(obj.bytes); if (crc != info.crc) { _setTextCallBack("文件热更新CRC比对错误 文件名:" + obj.url); SuperDebug.Log("文件热更新CRC比对错误 文件名:" + obj.url); return; } #if PLATFORM_PC || PLATFORM_ANDROID if (path.Equals(CODE_BYTES_NAME)) { codeBytes = obj.bytes; } else { SystemIO.SaveFile(Application.persistentDataPath + "/" + path, obj.bytes); } #else SystemIO.SaveFile(Application.persistentDataPath + "/" + path, obj.bytes); #endif if (data.dic.ContainsKey(path)) { data.dic[path] = info.version; } else { data.dic.Add(path, info.version); } loadNum--; //_setTextCallBack("正在更新:" + (_dic.Count - loadNum) + "/" + _dic.Count); loadSize += info.size; _setTextCallBack("正在更新:" + Math.Round((float)loadSize / (float)_allFileSize * 100) + "%(" + Math.Round((float)loadSize / 1024 / 1024, 1) + "/" + Math.Round((float)_allFileSize / 1024 / 1024, 1) + ")"); _setPercentCallBack((float)loadSize / (float)_allFileSize); if (loadNum == 0) { UpdateOver(_remoteVersion, _callBack); } }; WWWManager.Instance.LoadRemote(url, callBack); } }
private IEnumerator LoadCorotine(string _path, bool _isRemote, Action <WWW> _callBack, float _timeout, Action _timeoutCallBack) { 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; } if (_timeout == 0) { using (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); } _callBack(www); } } else { using (WWW www = new WWW(finalPath)){ float timer = 0.0f; bool failed = false; while (!www.isDone) { if (timer > _timeout) { failed = true; break; } timer += Time.unscaledDeltaTime; yield return(null); } if (failed) { _timeoutCallBack(); } else { _callBack(www); } } } loadOverCallBack(); }
private static void CreateAssetBundleDat(AssetBundleManifest manifest, BuildAssetBundleOptions _buildOptions, BuildTarget _buildTarget) { if (manifest == null) { return; } string[] abs = manifest.GetAllAssetBundles(); AssetBundle[] aaaa = new AssetBundle[abs.Length]; try{ List <UnityEngine.Object> assets = new List <UnityEngine.Object> (); List <string> assetNames = new List <string> (); List <string> assetBundleNames = new List <string> (); Dictionary <string, List <string> > result = new Dictionary <string, List <string> > (); for (int i = 0; i < abs.Length; i++) { AssetBundle ab = LoadAssetBundle("file:///" + Application.streamingAssetsPath + "/" + AssetBundleManager.path + abs[i]); // AssetBundle ab = AssetBundle.CreateFromFile(Application.streamingAssetsPath + "/" + AssetBundleManager.path + abs[i]); aaaa[i] = ab; string[] nn = ab.GetAllAssetNames(); foreach (string str in nn) { if (assetNames.Contains(str)) { SuperDebug.LogError("error!"); } else { assetNames.Add(str); UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(str); assets.Add(obj); assetBundleNames.Add(abs[i]); List <string> ll = new List <string>(); result.Add(str, ll); } } } for (int i = 0; i < assetNames.Count; i++) { string name = assetNames[i]; UnityEngine.Object obj = assets[i]; List <string> list = result[name]; UnityEngine.Object[] sss = EditorUtility.CollectDependencies(new UnityEngine.Object[] { obj }); foreach (UnityEngine.Object dd in sss) { if (dd != obj) { if (assets.Contains(dd)) { string assetBundleName = assetBundleNames[assets.IndexOf(dd)]; if (!list.Contains(assetBundleName)) { list.Add(assetBundleName); } } } } } FileInfo fi = new FileInfo(Application.streamingAssetsPath + "/" + AssetManager.dataName); if (fi.Exists) { fi.Delete(); } FileStream fs = fi.Create(); BinaryWriter bw = new BinaryWriter(fs); AssetManagerDataFactory.SetData(bw, assetNames, assetBundleNames, result); fs.Flush(); bw.Close(); fs.Close(); fs.Dispose(); }catch (Exception e) { Debug.Log("error:" + e.Message); }finally{ foreach (AssetBundle aaa in aaaa) { aaa.Unload(true); } } }
private static void setData(FieldInfo _info, CsvBase _csv, string _data) { string str = "setData:" + _info.Name + " " + _info.FieldType.Name + " " + _data + " " + _data.Length + Environment.NewLine; //SuperDebug.Log(str); try { switch (_info.FieldType.Name) { case "Int32": if (string.IsNullOrEmpty(_data)) { _info.SetValue(_csv, 0); } else { _info.SetValue(_csv, Int32.Parse(_data)); } break; case "String": _info.SetValue(_csv, _data); break; case "Boolean": _info.SetValue(_csv, _data == "1" ? true : false); break; case "Single": if (string.IsNullOrEmpty(_data)) { _info.SetValue(_csv, 0); } else { _info.SetValue(_csv, float.Parse(_data)); } break; case "Int32[]": int[] intResult; if (!string.IsNullOrEmpty(_data)) { string[] strArr = _data.Split('$'); intResult = new int[strArr.Length]; for (int i = 0; i < strArr.Length; i++) { intResult[i] = Int32.Parse(strArr[i]); } } else { intResult = new int[0]; } _info.SetValue(_csv, intResult); break; case "String[]": string[] stringResult; if (!string.IsNullOrEmpty(_data)) { stringResult = _data.Split('$'); } else { stringResult = new string[0]; } _info.SetValue(_csv, stringResult); break; case "Boolean[]": bool[] boolResult; if (!string.IsNullOrEmpty(_data)) { string[] strArr = _data.Split('$'); boolResult = new bool[strArr.Length]; for (int i = 0; i < strArr.Length; i++) { boolResult[i] = strArr[i] == "1" ? true : false; } } else { boolResult = new bool[0]; } _info.SetValue(_csv, boolResult); break; default: float[] floatResult; if (!string.IsNullOrEmpty(_data)) { string[] strArr = _data.Split('$'); floatResult = new float[strArr.Length]; for (int i = 0; i < strArr.Length; i++) { floatResult[i] = float.Parse(strArr[i]); } } else { floatResult = new float[0]; } _info.SetValue(_csv, floatResult); break; } } catch (Exception e) { SuperDebug.LogError(str + " " + e.ToString()); } }
private static void CreateAssetBundleDat(AssetBundleManifest manifest, bool _useAssembly) { if (manifest == null) { return; } string[] abs = manifest.GetAllAssetBundles(); AssetBundle[] aaaa = new AssetBundle[abs.Length]; try{ List <UnityEngine.Object> assets = new List <UnityEngine.Object> (); List <string> assetNames = new List <string> (); List <string> assetBundleNames = new List <string> (); Dictionary <string, List <string> > result = new Dictionary <string, List <string> > (); for (int i = 0; i < abs.Length; i++) { AssetBundle ab = LoadAssetBundle("file:///" + Application.streamingAssetsPath + "/" + AssetBundleManager.path + abs[i]); // AssetBundle ab = AssetBundle.CreateFromFile(Application.streamingAssetsPath + "/" + AssetBundleManager.path + abs[i]); aaaa[i] = ab; string[] nn = ab.GetAllAssetNames(); foreach (string str in nn) { if (assetNames.Contains(str)) { SuperDebug.LogError("error!"); } else { assetNames.Add(str); UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(str); assets.Add(obj); assetBundleNames.Add(abs[i]); List <string> ll = new List <string>(); result.Add(str, ll); } } } for (int i = 0; i < assetNames.Count; i++) { string name = assetNames[i]; UnityEngine.Object obj = assets[i]; List <string> list = result[name]; UnityEngine.Object[] sss = EditorUtility.CollectDependencies(new UnityEngine.Object[] { obj }); foreach (UnityEngine.Object dd in sss) { if (dd != obj) { if (assets.Contains(dd)) { string assetBundleName = assetBundleNames[assets.IndexOf(dd)]; if (!list.Contains(assetBundleName)) { list.Add(assetBundleName); } } } } } if (_useAssembly) { FileStream fs = new FileStream(Application.streamingAssetsPath + "/" + AssemblyShell.ASSEMBLY_FILE_NAME, FileMode.Open); byte[] bytes = new byte[fs.Length]; fs.Read(bytes, 0, (int)fs.Length); fs.Close(); Assembly ass = Assembly.Load(bytes); Type type = ass.GetType("xy3d.tstd.lib.assetManager.AssetManager"); type.GetMethod("CreateAssetData").Invoke(null, new object[] { assetNames, assetBundleNames, result }); } else { AssetManager.CreateAssetData(assetNames, assetBundleNames, result); } }catch (Exception e) { Debug.Log("error:" + e.Message); }finally{ foreach (AssetBundle aaa in aaaa) { aaa.Unload(true); } } }
private void GetAssemblyOriginal(bool _result) { SuperDebug.Log("没有找到新的代码文件!!!" + _result); Application.LoadLevel("main"); }
public void Close() { SuperDebug.VeryImportantAssert(base.view != null, "view is null!"); this.Destroy(); }
private static void Fix(GameObject _go) { CanvasRenderer r = _go.GetComponent <CanvasRenderer>(); if (r != null) { Image img = _go.GetComponent <Image>(); Text text = _go.GetComponent <Text>(); RawImage rawImg = _go.GetComponent <RawImage>(); if (img == null && text == null && rawImg == null) { GameObject.DestroyImmediate(r, true); } } MonoBehaviour[] b = _go.GetComponents <MonoBehaviour>(); foreach (MonoBehaviour m in b) { if (m == null) { SuperDebug.LogErrorFormat("发现脚本丢失 root:{0}--->{1}", _go.transform.root.name, _go.name); break; } } Button bt = _go.GetComponent <Button>(); if (bt != null) { int num = bt.onClick.GetPersistentEventCount(); for (int i = 0; i < num; i++) { UnityEngine.Object t = bt.onClick.GetPersistentTarget(i); string methodName = bt.onClick.GetPersistentMethodName(i); if (!(t is MonoBehaviour)) { Debug.LogError("Button target gameObject is not a MonoBehaviour! GameObject.name:" + _go.name + " root.name:" + _go.transform.root.gameObject.name); } else { MonoBehaviour script = t as MonoBehaviour; MethodInfo mi = script.GetType().GetMethod(methodName); if (mi == null) { Debug.LogError("Button target method is not found in target! GameObject.name:" + _go.name + " root.name:" + _go.transform.root.gameObject.name); } } } } // SuperList superList = _go.GetComponent<SuperList>(); // // if(superList != null){ // // Mask mask = _go.GetComponent<Mask>(); // // if(mask != null){ // // GameObject.DestroyImmediate(mask); // // Image img = _go.GetComponent<Image>(); // // GameObject.DestroyImmediate(img); // // _go.AddComponent<RectMask2D>(); // // _hasChange = true; // } // } for (int i = 0; i < _go.transform.childCount; i++) { Fix(_go.transform.GetChild(i).gameObject); } }