public void SendData <T>(BaseProto _data, Action <T> _callBack) where T : BaseProto { if (_data.type != PROTO_TYPE.C2S) { SuperDebug.LogError("sendError!"); return; } Action <BaseProto> callBack = delegate(BaseProto obj) { _callBack(obj as T); }; lock (sendPool) { if (isWaittingForResponse) { sendPool.Add(_data); callBackPool.Add(callBack); return; } else { isWaittingForResponse = true; nowCallBack = callBack; } } SendDataReal(_data); }
void Update() { Plane[] planes = GeometryUtility.CalculateFrustumPlanes(Camera.main); if (!GeometryUtility.TestPlanesAABB(planes, bounds[0])) { if (GeometryUtility.TestPlanesAABB(planes, bounds[1])) { gameObject.transform.Translate(gameObject.transform.right * bounds[0].size.x); copy.SetActive(false); RefreshBounds(); } else if (GeometryUtility.TestPlanesAABB(planes, bounds[2])) { gameObject.transform.Translate(gameObject.transform.right * -bounds[0].size.x); copy.SetActive(false); RefreshBounds(); } else { SuperDebug.LogError("error!!!"); } } else { if (GeometryUtility.TestPlanesAABB(planes, bounds[1])) { if (!copy.activeSelf) { copy.transform.position = gameObject.transform.position; copy.transform.Translate(copy.transform.right * bounds[0].size.x); copy.SetActive(true); } } else if (GeometryUtility.TestPlanesAABB(planes, bounds[2])) { if (!copy.activeSelf) { copy.transform.position = gameObject.transform.position; copy.transform.Translate(copy.transform.right * -bounds[0].size.x); copy.SetActive(true); } } else { if (copy.activeSelf) { copy.SetActive(false); } } } }
private void ReceiveHeadEnd(IAsyncResult _result) { Debug.Log("ReceiveHeadEnd!"); int length = socket.EndReceive(_result); if (length == 0) { SuperDebug.LogError("Disconnect!!!"); } else if (length < headLength) { headLength = headLength - length; headOffset = headOffset + length; ReceiveHead(); } else { bodyLength = BitConverter.ToInt32(headBuffer, 0); bodyOffset = 0; headLength = HEAD_LENGTH; headOffset = 0; ReceiveBody(); } }
public T GetAsset <T> (string _name, Action <T> _callBack) where T : UnityEngine.Object { #if USE_ASSETBUNDLE AssetManagerUnit <T> unit; if (!dic.ContainsKey(_name)) { unit = new AssetManagerUnit <T> (_name); dic.Add(_name, unit); } else { unit = dic [_name] as AssetManagerUnit <T>; } unit.Load(_callBack); return(null); #else T data = AssetDatabase.LoadAssetAtPath <T> (_name); if (data == null) { SuperDebug.LogError("Resource load fail:" + _name); } _callBack(data); return(data); #endif }
public static void SetIsOpen(bool _isOpen, string _str) { SuperGraphicRaycastScript.Instance.isOpen = SuperGraphicRaycastScript.Instance.isOpen + (_isOpen ? 1 : -1); if (SuperGraphicRaycastScript.Instance.isOpen > 1) { SuperDebug.LogError("SuperGraphicRaycast.SetOpen error!"); } }
public AssetManagerData GetData(string _name) { string name = _name.ToLower(); if (!dataDic.ContainsKey(name)) { SuperDebug.LogError("AssetBundle中没有找到Asset:" + _name); } return(dataDic [name]); }
public static Dictionary <int, T> GetDic <T>() where T : CsvBase { Type type = typeof(T); if (!dic.ContainsKey(type)) { SuperDebug.LogError("not find: " + type); } return(dic[type] as Dictionary <int, T>); }
public static T GetData <T>(int _id) where T : CsvBase { Dictionary <int, T> tmpDic = dic[typeof(T)] as Dictionary <int, T>; if (!tmpDic.ContainsKey(_id)) { SuperDebug.LogError(typeof(T).Name + "表中未找到ID为:" + _id + "的行!"); } return(tmpDic[_id]); }
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!"); } }
public AssetManagerData GetData(string _name) { string name = _name.ToLower(); AssetManagerData data; if (!dataDic.TryGetValue(name, out data)) { SuperDebug.LogError("AssetBundle中没有找到Asset:" + _name); } return(data); }
public static T GetData <T>(int _id) where T : CsvBase { Dictionary <int, T> tmpDic = dic[typeof(T)] as Dictionary <int, T>; T data; if (!tmpDic.TryGetValue(_id, out data)) { SuperDebug.LogError(typeof(T).Name + "表中未找到ID为:" + _id + "的行!"); } return(data); }
public static Dictionary <int, T> GetDic <T>() where T : CsvBase { Type type = typeof(T); IDictionary data; if (!dic.TryGetValue(type, out data)) { SuperDebug.LogError("not find: " + type); } return(data as Dictionary <int, T>); }
public void PreloadGameObject(string _path, Action _callBack) { if (dic.ContainsKey(_path)) { SuperDebug.LogError("PreloadGameObject error path:" + _path); return; } GameObjectFactoryUnit unit = new GameObjectFactoryUnit(_path); dic.Add(_path, unit); unit.PreloadGameObject(_callBack); }
public void SetOpen(bool _b) { m_isOpen = m_isOpen + (_b ? 1 : -1); if (m_isOpen == 0) { if (objs.Count > 0) { objs.Clear(); } } else if (m_isOpen > 1) { SuperDebug.LogError("SuperGraphicRaycast.SetOpen error!"); } }
public static T GetData <T>(int _id) where T : CsvBase { // @todo 需删除的临时代码 (KFC) if (dic.ContainsKey(typeof(T)) == false) { SuperDebug.LogError(typeof(T).Name + "表未添加"); } Dictionary <int, T> tmpDic = dic[typeof(T)] as Dictionary <int, T>; if (!tmpDic.ContainsKey(_id)) { SuperDebug.LogError(typeof(T).Name + "表中未找到ID为:" + _id + "的行!"); } return(tmpDic[_id]); }
// 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); }
/// <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!"); } }
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 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 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 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 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); } } }
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); } } } }