public T RegistDocument <T>() where T : XDocument, new() { if (documents == null) { documents = new Dictionary <uint, XDocument>(); } uint uid = XCommon.singleton.XHash(typeof(T).Name); if (documents.ContainsKey(uid)) { XDebug.Log("has registed document ", typeof(T).Name); return(documents[uid] as T); } else { T doc = new T(); doc.OnInitial(); documents.Add(uid, doc); return(doc); } }
//同步加载 public void Load(IXAssetManager manager, EnumFileLocation location, EnumBundleType bundleType, string name) { m_AssetManager = manager; m_BundleName = name; m_dependencies.Clear(); var dependencies = manager.GetDependencies(m_BundleName); if (dependencies != null) { m_dependencies.AddRange(dependencies); foreach (var dependency in dependencies) { manager.LoadBundle(dependency); } } var fullPath = XABUtilities.GetBundleFullPath(location, bundleType, name); XDebug.Log(XABConst.Tag, $"加载 {fullPath}"); SetValue(_LoadInternal(fullPath)); }
public bool Send([NotNull] Component sender, int signal, object data = null) { if (sender == null) { throw new ArgumentNullException("sender"); } SignalPacket signalPacket = new SignalPacket { Data = data, Sender = sender, Signal = signal }; AddSignalPacket(signalPacket); if (!ReceiverLookup.ContainsKey(signal)) { signalPacket.NoReceivers = true; return(false); } List <ISignalReceiver> receivers = ReceiverLookup[signal].ToList(); if (receivers.Any(r => r == null)) { receivers = ReceiverLookup[signal] = receivers.Where(r => r != null).ToList(); } #if XDEBUG XDebug.Log(sender, "{0} --[ {1} ]--> {2}", sender.name + ":" + sender.GetType().Name, Signal.LookupName(signal), receivers.AggregateString(", ") + (data != null ? " (" + data + ")" : "")); #endif receivers.ForEach(r => { if (r != null) { r.Receive(sender, data); } }); return(true); }
public static void Build(bool fast) { _scenes = FindEnabledEditorScenes(); EditorUserBuildSettings.SwitchActiveBuildTarget(_target); if (Directory.Exists(_targetDir)) { try { Directory.Delete(_targetDir, true); } catch (System.Exception e) { XDebug.Log(e.Message); } } Directory.CreateDirectory(_targetDir); if (!fast) { XPriorBuild.OnPriorBuild(fast, EditorUserBuildSettings.activeBuildTarget); } string lastName = ""; if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android) { lastName = ".apk"; } else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows) { lastName = ".exe"; } string dest = Path.Combine(_targetDir, "dnasset" + lastName); string res = BuildPipeline.BuildPlayer(_scenes, dest, _target, _build); string macro = XBuild.Macro; PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, macro); PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android, macro); PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, macro); if (!fast) { XPostBuild.OnPostBuild(fast, EditorUserBuildSettings.activeBuildTarget); } EditorUtility.DisplayDialog("Package Build Finish", "Package Build Finish!(" + res + ")", "OK"); HelperEditor.Open(_targetDir); }
public override void OnEnter(XUIWindow obj) { XDebug.Log(XUIConst.Tag, $"XUIWindowTask_Hide enter {obj.name}"); if (obj.mono.hideAnim != null) { if (obj.mono.hideAnim == obj.mono.showAnim) { obj.mono.showAnim.Revs(delegate { m_complete = true; }); } else { obj.mono.hideAnim.Play(delegate { m_complete = true; }); } m_complete = false; } else { m_complete = true; } obj.isHideAnimating = true; }
public void Broadcast(int eventType) { #if LOG_ALL_MESSAGES || LOG_BROADCAST_MESSAGE XDebug.Log("MESSENGER\t" + System.DateTime.Now.ToString("hh:mm:ss.fff") + "\t\t\tInvoking \t\"" + eventType + "\""); #endif OnBroadcasting(eventType); Delegate d; if (mEventTable.TryGetValue(eventType, out d)) { CallbackE callback = d as CallbackE; if (callback != null) { callback(); } else { throw CreateBroadcastSignatureException(eventType); } } }
//Six parameters public void Broadcast <T, U, V, X, Y, Z>(int eventType, T arg1, U arg2, V arg3, X arg4, Y arg5, Z arg6) { #if LOG_ALL_MESSAGES || LOG_BROADCAST_MESSAGE XDebug.Log("MESSENGER\t" + System.DateTime.Now.ToString("hh:mm:ss.fff") + "\t\t\tInvoking \t\"" + eventType + "\""); #endif OnBroadcasting(eventType); Delegate d; if (mEventTable.TryGetValue(eventType, out d)) { CallbackE <T, U, V, X, Y, Z> callback = d as CallbackE <T, U, V, X, Y, Z>; if (callback != null) { callback(arg1, arg2, arg3, arg4, arg5, arg6); } else { throw CreateBroadcastSignatureException(eventType); } } }
public static void Open(string path) { XDebug.Log("Open:", path); if (File.Exists(path)) { path = Path.GetDirectoryName(path); } if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } #if UNITY_EDITOR_OSX string shell = basepath + "/Shell/open.sh"; // Debug.Log("shell: "+shell+" exist: "+System.IO.File.Exists(shell)); string arg = path; string ex = shell + " " + arg; System.Diagnostics.Process.Start("/bin/bash", ex); #elif UNITY_EDITOR_WIN path = path.Replace("/", "\\"); System.Diagnostics.Process.Start("explorer.exe", path); #endif }
//Load the image from the specified path and generates a Texture2D. //指定パスから画像を読み込み、テクスチャを生成する。 private static Texture2D LoadToTexture2D(string path, int width, int height, TextureFormat format, bool mipmap, FilterMode filter) { if (string.IsNullOrEmpty(path)) { return(null); } try { byte[] bytes = File.ReadAllBytes(path); Texture2D texture = new Texture2D(width, height, format, mipmap); texture.LoadImage(bytes); texture.filterMode = filter; texture.Compress(false); return(texture); } catch (Exception e) { XDebug.Log(e.ToString()); return(null); } }
public void AddData(string assetName, string bundleName, string assetPath, bool isStatic) { if (m_flags.ContainsKey(assetName)) { XDebug.Log(XABConst.Tag, $"资源{assetName}重复 {assetPath} 已经存在于{m_flags[assetName].AssetPath}"); return; } var data = new Data(); data.AssetName = assetName.ToLower(); data.AssetBundleName = bundleName.ToLower(); data.AssetPath = assetPath; m_flags.Add(assetName, data); if (isStatic) { StaticDatas.Add(data); } else { HotfixDatas.Add(data); } }
private static bool _CheckAnimator(AnimatorController controller, string path) { if (controller.layers.Length == 1) { AnimatorControllerLayer layer = controller.layers[0]; AnimatorStateMachine asm = layer.stateMachine; if (asm.states.Length == 1) { AnimatorState state = asm.defaultState; XDebug.Log("state name: ", state.name, " cotroll: ", controller.name); if (state.name != controller.name) { XDebug.LogError(string.Format("Animator name error controller name:{0} state name:{1} path:{2}", controller.name, state.name, path)); } } } else { XDebug.LogError(string.Format("Not 1 layer:{0} Count:{1}", controller.name, controller.layers.Length)); } return(true); }
//Callback handler for 'LocalizeLanguageChanger' public void OnLanguageChanged(SystemLanguage language) { if (language == SystemLanguage.Unknown) { XDebug.Log("Localize language changed : (System language)"); } else { XDebug.Log("Localize language changed : " + language); } localizeLanguage = language; //Sync dropdown on start up (Basically, when load setting (PlayerPrefs) and changed only) if (localizeDropdown != null && language != SystemLanguage.Unknown) { if (!localizeDropdown.IsSelectedLanguage(language)) { localizeDropdown.SetLanguage(language); } } }
//Register 'StorageSaveFileController.OnResultInfo' callback public void OnSaveFile(ContentInfo info) { XDebug.Log("OnSaveFile : " + info); XDebug.Log("path = " + info.path); if (!string.IsNullOrEmpty(info.path)) { string ext = Path.GetExtension(info.path); XDebug.Log("ext = " + ext); switch (ext) { case ".csv": SaveCsvData(info.path); break; case ".json": SaveJsonData(info.path); break; case ".txt": if (displayText != null && !string.IsNullOrEmpty(displayText.text)) { if (SaveText(displayText.text, info.path)) { XDebug.Log("Save to : " + info.path); } } break; default: break; } } else { XDebug.Log("'path' is empty."); } }
JsonData jsonData; //Loaded parameter buffer //Required : <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> (or 'WRITE_EXTERNAL_STORAGE') //Load specified file as JSON data. //(*) To read to External Storage on Android, you need permission in the 'AndroidManifest.xml' file. // //指定ファイルをJSONデータとして読み込む。 //※Android で External Storage に読み込みをするには、「AndroidManifest.xml」にパーミッションが必要。 public void LoadJsonData(string path) { XDebug.Log("LoadJsonData : path = " + path); if (string.IsNullOrEmpty(path)) { return; } string text = LoadText(path); if (!string.IsNullOrEmpty(text)) { jsonData = JsonUtility.FromJson <JsonData>(text); XDebug.Log(jsonData); if (toastControl != null) { toastControl.Show(loadSuccessMessage.Text); } } }
//Share screenshot public void ShareScreenshot() { if (lastContent == null) { return; } string uri = lastContent.uri; string path = lastContent.path; XDebug.Log("Last content : path = " + path + ", uri = " + uri); if (string.IsNullOrEmpty(uri)) { return; } if (sendTextControl != null) { sendTextControl.Send(shareText.TextByLanguage(localizeLanguage), uri); } }
public bool saveFile(string fileName) { try { XDebug.Log("saveFile filename:" + fileName); string result = save(); // 目录要先创建 // 创建文件夹,拷贝文件 XUtil.assureDirectory(fileName); FileStream fs = File.Open(fileName, FileMode.Create); byte[] data = new UTF8Encoding().GetBytes(result); fs.Write(data, 0, data.Length); fs.Close(); } catch (Exception e) { XDebug.LogError(e.Message); return(false); } return(true); }
//Callback handler when not supported, security is turned off. public void DeviceCredentialsError(string message) { XDebug.Log("Device Credentials : " + message); if (message == "ERROR_NOT_SUPPORTED") { if (OnAPIAlert != null && 0 < apiLevel && apiLevel < 21) { OnAPIAlert.Invoke(); return; } if (OnNotSupportAlert != null && apiLevel >= 21) { OnNotSupportAlert.Invoke(); return; } } if (OnToast != null) { OnToast.Invoke(message); } }
//Required : '<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />' (or 'WRITE_EXTERNAL_STORAGE') in 'AndroidManifest.xml'. //Load from a text file //(*) To read from External Storage on Android, you need permission in the 'AndroidManifest.xml' file. // //テキストをファイルから読み込む //※Android で External Storage から読み込みをするには、「AndroidManifest.xml」にパーミッションが必要。 private string LoadText(string path) { StringBuilder sb = new StringBuilder(1024); try { using (StreamReader reader = new StreamReader(path)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); sb.Append(line).Append("\n"); } } } catch (Exception e) { XDebug.Log(e.Message); return(null); } return(sb.ToString()); }
public void RunScript(string funcName) { if (!_LevelScripts.ContainsKey(funcName)) { return; } if (_CmdQueue != null && _CmdQueue.Count > 0) { XDebug.Log("script function append"); } if (_CmdQueue.Count == 0) { _currentCmd = null; } List <LevelCmdDesc> funcCmds = _LevelScripts[funcName]; for (int i = 0; i < funcCmds.Count; i++) { funcCmds[i].Reset(); _CmdQueue.Add(funcCmds[i]); } Update(); }
//CustomDialogController demo (When 'OK' button pressed) public void OnCustom(Dictionary <string, string> dic) { string str = string.Join(", ", dic.Select(e => e.Key + "=" + e.Value).ToArray()); XDebug.Log(str); if (dic.ContainsKey("reset") && dic["reset"].ToLower() == "true") //'Reset switch' in dialog { if (customControl != null) { customControl.ResetValue(); } ShowToastSettingReset(); } else { if (toastControl != null) { toastControl.Show(str); } } }
//Attach the image to an email and show //(*) However, when adding an attached file, it is the same method as 'Send text + attached file' (Other than the mailer is displayed). //※ただし、添付ファイルを追加する場合は、「テキスト送信+添付ファイル」と同じ方法になる(メーラー以外も表示される)。 public void SendMailScreenshot() { if (lastContent == null) { return; } string uri = lastContent.uri; string path = lastContent.path; XDebug.Log("Last content : path = " + path + ", uri = " + uri); if (string.IsNullOrEmpty(uri)) { return; } if (mailerControl != null) { mailerControl.SetAttachment(uri); mailerControl.Show(); } }
/// <summary> /// Returns the previous keyframe closest to the specified frame, if none can be found returns the current frame. /// </summary> /// <param name="index"></param> /// <returns>Returns current frame if no keyframes are found.</returns> public Frame BestPreviousKeyframe(int index) { //// First try to get best keyframe for (int off = 1; off < halfFrameCount; ++off) { int offsetIndex = index - off; offsetIndex = (offsetIndex < 0) ? offsetIndex + nstFrameCount : offsetIndex; Frame frame = frames[offsetIndex]; if (frame.rootBitCullLevel == BitCullingLevel.NoCulling && Time.time - frame.packetArriveTime < nst.frameUpdateInterval * (off + quaterFrameCount)) // rough estimate that the frame came in this round and isn't a full buffer cycle old { return(frame); } } //Debug.Log( XDebug.Log(!XDebug.logInfo ? null : (Time.time + " NST:" + nst.NstId + " Could not find a recent keyframe in the buffer history, likely very bad internet loss is responsible. " + "Some erratic player movement is possible. " + nst.name)); return(currentFrame); }
public override void Enter() { var assetInfoManager = m_manager.AssetInfoManager; m_serverAddress = m_manager.serverAddress; #if UNITY_EDITOR m_serverAddress = EditorPrefs.GetString(XABConst.EKResUrl); if (string.IsNullOrEmpty(m_serverAddress)) { Debug.LogError("没有配置url"); return; } m_serverAddress += "/_filelist.json"; #endif m_server_filelist = null; m_client_filelist = XFileList.LoadFileList(XABUtilities.GetResPath(EnumFileLocation.Client, EnumBundleType.Hotfix)); m_origin_filelist = XFileList.LoadFileList(XABUtilities.GetResPath(EnumFileLocation.Stream, EnumBundleType.Hotfix)); if (m_client_filelist == null) { m_client_filelist = new XFileList(); } if (m_origin_filelist == null) { m_origin_filelist = new XFileList(); } XWebRequestManagerSingle.GetUrl(m_serverAddress, delegate(string error, string responseData) { if (!string.IsNullOrEmpty(error)) { return; } m_server_filelist = JsonUtility.FromJson <XFileList>(responseData); XDebug.Log(XABConst.Tag, m_server_filelist.ToLog()); }); }
public static void Rcv(ref UdpBitStream bitstream, ref UdpBitStream outstream, bool mirror, int clientId) { bool isPing = bitstream.ReadBool(); // if this is a ping from a client, a time delta should follow (mirror means this is the server, and this pass is the server pass) if (isPing && mirror && clientId != MasterNetAdapter.MasterClientId) { float clientHeldTime = .001f * bitstream.ReadInt(10); float rtt = (Time.time - svrPingInitiateTime) - clientHeldTime; if (RTT.ContainsKey(clientId)) { RTT[clientId] = RTT[clientId] * OLD_SAMP_WEIGHT + rtt * NEW_SAMP_WEIGHT; } else { RTT.Add(clientId, rtt); } //Debug.Log( XDebug.Log(!XDebug.logInfo ? null : "MasterRTT ping result " + clientId + " <b>" + RTT[clientId] + " </b> plus " + clientHeldTime + " of client waiting for next outgoing tick."); } // this is a dumb client and it just got a ping from server else if (isPing && !MasterNetAdapter.ServerIsActive) { clientNeedsToRespondToPing = true; clntPingArriveTime = Time.time; } // We don't mirror out pings. The conversation is strictly Server > Player > Server if (mirror) { outstream.WriteBool(false); } }
// Use this for initialization private void Start() { //Get Device API Level if (apiLevelText != null) { XDebug.Log(SystemInfo.operatingSystem); #if !UNITY_EDITOR && UNITY_ANDROID int apiLevel = AndroidPlugin.GetAPILevel(); apiLevelText.text = "Device API Level = " + apiLevel; XDebug.Log("Device API Level = " + apiLevel); #endif } //Get system language if (languageText != null) { SystemLanguage lang = Application.systemLanguage; var strVal = Enum.GetName(typeof(SystemLanguage), lang); languageText.text = "Language = " + (int)lang + " (" + strVal + ")"; } if (hardVolToggle != null) { hardVolToggle.isOn = FindObjectOfType <HardVolumeController>().HardOperation; OnHardVolumeOperationChanged(hardVolToggle.isOn); } if (vibratorControl == null) { vibratorControl = FindObjectOfType <VibratorController>(); if (vibratorControl != null) { XDebug.Log("IsSupportedVibrator = " + vibratorControl.IsSupportedVibrator); } } }
//Hide the UI and execute the screenshot. If save the screenshot successfully, run MeidaScanner. private IEnumerator StartScreenshot(string path) { isSaving = true; foreach (var item in hideUIOnScreenshot) { item.SetActive(false); } yield return(null); yield return(StartCoroutine(SaveScreenshotPng(path))); foreach (var item in hideUIOnScreenshot) { item.SetActive(true); } if (isSaving) { if (OnToast != null) { OnToast.Invoke("Save ScreenShot completed"); } if (OnMediaScan != null) { OnMediaScan.Invoke(path); } XDebug.Log("Save to : " + path); } yield return(null); isSaving = false; }
public void DynamicCustom() { DivisorItem divisorItem = new DivisorItem(1); TextItem textItem = new TextItem("Dynamic Test!", Color.blue); SwitchItem switchItem1 = new SwitchItem("Switch item1", "switch1", true); SwitchItem switchItem2 = new SwitchItem("Switch item2", "switch2", false); SliderItem sliderItem1 = new SliderItem("Slider item1", "slider1", 50, 0, 100, 0, 0, ""); SliderItem sliderItem2 = new SliderItem("Slider item2", "slider2", 0.5f, 0, 1, 2, 0, ""); ToggleItem toggleItem = new ToggleItem( new String[] { "Toggle1", "Toggle2" }, "toggles", new String[] { "toggle value1", "toggle value2" }, "value2"); DialogItem[] items = new DialogItem[] { divisorItem, textItem, switchItem1, switchItem2, sliderItem1, sliderItem2, toggleItem }; if (customControl != null) { customControl.SetItem(items); XDebug.Log("CurrentValue : " + customControl.CurrentValue.Select(e => e.Key + "=" + e.Value).Aggregate((s, a) => s + ", " + a)); } }
static void move_all(BuildTarget buildTarget) { delStreamingAssets(); XPack pack = new XPack(); pack.setInfo(buildTarget); XUtil.copyDirectory(pack.targetDir, "Assets/StreamingAssets", true); AssetDatabase.Refresh(); // publish目录 string versionDir = pack.getVersionDir(publishDir, "v" + version); // 清除所有东西 XUtil.clearDirectory(versionDir); XUtil.copyDirectory(pack.targetDir, versionDir, true); build(pack, versionDir); // 拷贝单个文件 XDebug.Log(versionDir + "assets/ver.json" + "=>" + pack.getPublishDir(publishDir) + "ver.json"); XUtil.copyFile(versionDir + "assets/ver.json", pack.getPublishDir(publishDir) + "ver.json"); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Alpha1)) { m_EventManager.PostEvent("test1", 100); } if (Input.GetKeyDown(KeyCode.Alpha2)) { m_EventManager.PostEvent("test2", 100, 200); } if (Input.GetKeyDown(KeyCode.Alpha3)) { m_EventManager.PostEvent("test3", 100, 200, 300); } if (Input.GetKeyDown(KeyCode.Alpha4)) { m_EventManager.PostEvent <XSampleEvent1>("test4", (evt) => { evt.value = 999; }); } if (Input.GetKeyDown(KeyCode.L)) { XDebug.Log("XObjectPool", XObjectPool.DumpLog()); } }
public void OnListenerRemoving(int eventType, Delegate listenerBeingRemoved) { #if LOG_ALL_MESSAGES XDebug.Log("MESSENGER OnListenerRemoving \t\"" + eventType + "\"\t{" + listenerBeingRemoved.Target + " -> " + listenerBeingRemoved.Method + "}"); #endif if (mEventTable.ContainsKey(eventType)) { Delegate d = mEventTable[eventType]; if (d == null) { throw new ListenerException(string.Format("Attempting to remove listener with for event type \"{0}\" but current listener is null.", eventType)); } else if (d.GetType() != listenerBeingRemoved.GetType()) { throw new ListenerException(string.Format("Attempting to remove listener with inconsistent signature for event type {0}. Current listeners have type {1} and listener being removed has type {2}", eventType, d.GetType().Name, listenerBeingRemoved.GetType().Name)); } } else { throw new ListenerException(string.Format("Attempting to remove listener for type \"{0}\" but Messenger doesn't know about this event type.", eventType)); } }