private void TryRegister(JSONStorable storable) { var bindings = new List <object>(); storable.SendMessage("OnBindingsListRequested", bindings, SendMessageOptions.DontRequireReceiver); if (bindings.Count > 0) { var actions = new List <JSONStorableAction>(); var floats = new List <JSONStorableFloat>(); foreach (var binding in bindings) { if (!(TryAdd(actions, binding) || TryAdd(floats, binding))) { SuperController.LogError($"{nameof(Sender)}: Received unknown binding type {binding.GetType()} from {storable.name} in atom {storable.containingAtom?.name ?? "(no containing atom)"}."); } } _receivers.Add(new Receiver { storable = storable, actions = actions, floats = floats }); SuperController.LogMessage($"{nameof(Sender)}: Registered {actions.Count + floats.Count} bindings"); } }
public void Log(string additional = null) { if (_shouldLog) { SuperController.LogMessage($"{_identifier} {additional} [{_stopwatch.ElapsedMilliseconds}ms]", false); } }
protected void SyncfloatTarget(string floatTargetName) { floatTarget = null; if (storableSelected.storable != null && floatTargetName != null && floatTargetName != "None") { floatTarget = storableSelected.storable.GetFloatJSONParam(floatTargetName); if (floatTarget != null) { SuperController.LogMessage(">> " + floatTarget.val); if (!insideRestore) { currentValue.val = floatTarget.val; } currentValue.min = floatTarget.min; currentValue.max = floatTarget.max; currentValueSlider.gameObject.SetActive(true); } } else { floatTarget = null; currentValueSlider.gameObject.SetActive(false); } }
private void PrintDebugInfo() { SuperController.singleton.ClearMessages(); if (_lastStep == null) { SuperController.LogMessage("Director: Step (null)"); return; } var info = new System.Collections.Generic.List <string>(); info.Add("Step " + _lastStep.containingAtom.name); if (_navigationRigActive) { info.Add(" [cam]"); } if (_windowCameraActive) { info.Add(" [win]"); } var target = GetStepPassengerTarget(_lastStep); if (target != null) { info.Add(" [passenger]"); } if (_deactivateOnComplete) { info.Add(" [once]"); } info.Add(" time: " + _pattern.GetCurrentTimeCounter() + "s, step time: " + _lastStep.timeStep + "s/" + _pattern.GetTotalTime() + "s, dur: " + _lastStep.transitionToTime + "s, speed: " + _speedJSON.val); SuperController.LogMessage("Director: " + string.Join(", ", info.ToArray())); }
public string FileFingerPrint(string fileName) { fileName = FileManagerSecure.NormalizePath(fileName); #if LFE_DEBUG var sw = new Stopwatch(); sw.Start(); #endif var inBytes = FileManagerSecure.ReadAllBytes(fileName); #if LFE_DEBUG sw.Stop(); SuperController.LogMessage($"fingerprint: read {fileName} took: {sw.ElapsedMilliseconds}ms"); sw.Reset(); sw.Start(); #endif var outBytes = _md5.ComputeHash(inBytes); var sb = new StringBuilder(); for (var i = 0; i < outBytes.Length; i++) { sb.Append(outBytes[i].ToString("X2")); } var print = sb.ToString(); #if LFE_DEBUG sw.Stop(); SuperController.LogMessage($"fingerprint: hash {fileName} took: {sw.ElapsedMilliseconds}ms"); #endif return(print); }
public static void PrintTree(int indent, GameObject o, bool showScripts, string[] exclude, HashSet <GameObject> found) { if (found.Contains(o)) { SuperController.LogMessage("|" + new String(' ', indent) + " [" + o.tag + "] " + o.name + " {RECURSIVE}"); return; } if (o == null) { SuperController.LogMessage("|" + new String(' ', indent) + "{null}"); return; } if (exclude.Any(x => o.gameObject.name.Contains(x))) { return; } found.Add(o); SuperController.LogMessage( "|" + new String(' ', indent) + " [" + o.tag + "] " + o.name + " -> " + (showScripts ? string.Join(", ", o.GetComponents <MonoBehaviour>().Select(b => b.ToString()).ToArray()) : "") ); for (int i = 0; i < o.transform.childCount; i++) { var under = o.transform.GetChild(i).gameObject; PrintTree(indent + 4, under, showScripts, exclude, found); } }
private void StartUdp() { if (_client != null) { return; } try { var address = IPAddress.Parse(IpText.val); var port = int.Parse(PortText.val); var endpoint = new IPEndPoint(address, port); _client = new UdpClient { ExclusiveAddressUse = false }; _client.Client.Blocking = false; _client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); _client.Client.Bind(new IPEndPoint(IPAddress.Any, 0)); _client.Connect(endpoint); SuperController.LogMessage($"Upd started on port: {port}"); } catch (Exception e) { SuperController.LogError(e.ToString()); StopUdp(); } }
private void Paste() { try { if (animation.IsPlaying()) { return; } if (clipboard.entries.Count == 0) { SuperController.LogMessage("VamTimeline: Clipboard is empty"); return; } var time = animation.Time; var timeOffset = clipboard.time; foreach (var entry in clipboard.entries) { animation.Current.Paste(animation.Time + entry.time - timeOffset, entry); } SampleAfterRebuild(); } catch (Exception exc) { SuperController.LogError($"VamTimeline.{nameof(AtomPlugin)}.{nameof(Paste)}: " + exc); } }
public void PrintAvailableClips() { foreach (var y in EmbeddedAudioClipManager.singleton.embeddedClips) { SuperController.LogMessage(y.uid); } }
//UIDynamicToggle skipSaveRestoreToggle; protected void SyncStorable(string storableID) { try { var actionTargetChoices = new List <string> { "None" }; if (storableSelected.storable != null) { if (skipSaveRestore.val) { SuperController.LogMessage("skip.."); actionTargetChoices = storableSelected.storable.GetActionNames() .Where(action => !skipedAction.Any(action.StartsWith)).ToList(); } else { actionTargetChoices.AddRange(storableSelected.storable.GetActionNames()); } actionChooser.choices = actionTargetChoices; actionChooser.val = "None"; } actionButton.gameObject.SetActive(false); } catch (Exception e) { Debug.LogException(e); throw; } }
public void Paste() { try { if (!CanEdit()) { return; } if (clipboard.entries.Count == 0) { SuperController.LogMessage("Timeline: Clipboard is empty"); return; } var timeOffset = clipboard.time; foreach (var entry in clipboard.entries) { current.Paste(clipTime + entry.time - timeOffset, entry); } Sample(); } catch (Exception exc) { SuperController.LogError($"Timeline.{nameof(AtomAnimationEditContext)}.{nameof(Paste)}: {exc}"); } }
public void DumpButtonCallback() { try { // Obtain the currently selected clothes. DAZClothingItem clothes = GameObject .FindObjectsOfType <DAZClothingItem>() .Where(dci => dci.containingAtom == containingAtom) .Where(dci => dci.name == clothingItems.val) .DefaultIfEmpty((DAZClothingItem)null) .FirstOrDefault(); // Bug out if it doesn't exist. if (clothes == null) { SuperController.LogError($"Could not finding clothing item '{clothingItems.val}'"); return; } // Get the first skinwrap mesh. DAZMesh mesh = clothes .GetComponentsInChildren <DAZMesh>() .FirstOrDefault(); // Export OBJExporter exporter = new OBJExporter(); exporter.Export(clothes.name + ".obj", mesh.uvMappedMesh, mesh.uvMappedMesh.vertices, mesh.uvMappedMesh.normals, mesh.materials); } catch (Exception ex) { SuperController.LogMessage($"Could not export OBJ file for this clothing item: {ex}"); } }
public bool Init(string serverIp, int recvPort, int sendPort) { try { var address = IPAddress.Parse(serverIp); _sendEndPoint = new IPEndPoint(address, sendPort); } catch (Exception e) { SuperController.LogMessage(e.Message); return(false); } try { _udpClient = new UdpClient(recvPort); } catch (Exception e) { SuperController.LogMessage(string.Format("Failed to init recv on port {0} ({1})", recvPort, e.Message)); return(false); } _recvThread = new Thread(Receive); _recvThread.IsBackground = true; _listening = true; _recvThread.Start(); return(true); }
private float TargetAudioSourceTime() { var target = 0f; var offsetAnimationTime = (SuperController.singleton.motionAnimationMaster.GetCurrentTimeCounter() - SoundtrackOffset.val) / TargetTimescale.val; if (offsetAnimationTime < 0) { target = 0f; } else { var clip = GetSourceClip(); if (clip != null) { if (Source.loop) { target = offsetAnimationTime % clip.length; } else { target = Mathf.Min(offsetAnimationTime, clip.length); } } else { target = offsetAnimationTime; } } #if LFE_TRACE SuperController.LogMessage($"TargetAudioSourceTime = {target} offsetAnimationTime = {offsetAnimationTime}"); #endif return(target); }
private void Paste() { try { if (animation.isPlaying || SuperController.singleton.gameMode != SuperController.GameMode.Edit) { return; } if (clipboard.entries.Count == 0) { SuperController.LogMessage("VamTimeline: Clipboard is empty"); return; } var time = animation.clipTime; var timeOffset = clipboard.time; foreach (var entry in clipboard.entries) { animation.current.Paste(animation.clipTime + entry.time - timeOffset, entry); } animation.Sample(); } catch (Exception exc) { SuperController.LogError($"VamTimeline.{nameof(AtomPlugin)}.{nameof(Paste)}: {exc}"); } }
public void Start() { if (SyncWithAudioPlayingThrough.val == SyncWithAudioPlayingThrough.defaultVal) { SyncWithAudioPlayingThrough.val = GuessAudioSourceAtom(); #if LFE_DEBUG SuperController.LogMessage($"guessed atom: {SyncWithAudioPlayingThrough.val}"); #endif } if (SoundtrackOffset.val == SoundtrackOffset.defaultVal) { SoundtrackOffset.val = GuessDefaultOffset(); #if LFE_DEBUG SuperController.LogMessage($"guessed offset: {SoundtrackOffset.val}"); #endif } if (Source == null) { SuperController.LogError("Could not automatically find any audio sources. Open plugin panel for more instructions."); var error = $"No audio sources were automatically found when looking through possible soundtracks in this scene.\n\n" + $"Select the atom that will be playing the main soundtrack audio for your Scene Animation.\n"; CreateTextField(new JSONStorableString("_error", error)); return; } originalPitch = Source.pitch; originalTimescale = TimeControl.singleton.currentScale; }
/** * Custom debug logging */ public void Log(string message) { if (_debug) { SuperController.LogMessage($"[{this.storeId}]: {message}"); } }
void LogMessage(string message) { if (logMessages) { SuperController.LogMessage($"Triggerman: {message}"); } }
private static VersionMessage DetermineCatalogVersionCompatibility(string catalogDeapVersion, IEnumerable <VersionMessage> pluginMessages) { if (!string.IsNullOrEmpty(catalogDeapVersion)) { var catalogFieldsRemoved = int.Parse(catalogDeapVersion.Split('.').First()); var pluginFieldsRemoved = int.Parse(CATALOG_DEAP_VERSION.Split('.').First()); var catalogHasRemovedFields = catalogFieldsRemoved > pluginFieldsRemoved; // Catalog is newer and has removed fields. May Break. Plugin may ne expecting certain fields. var catalogHasExtraOldFields = catalogFieldsRemoved < pluginFieldsRemoved; // Catlog is older. Plugin has removed fields. No break. Catalog has fields that won't be used by the plugin. if (catalogHasRemovedFields) { SuperController.LogMessage($"WARNING: The catalog you are opening is newer and may not contain all neccessary fields (catalog version: {catalogDeapVersion}, your version: {CATALOG_DEAP_VERSION}). Please update the plugin."); } var catalogFieldsAdded = int.Parse(catalogDeapVersion.Split('.')[2]); var pluginFieldsAdded = int.Parse(CATALOG_DEAP_VERSION.Split('.')[2]); var catalogHasNewFields = catalogFieldsAdded > pluginFieldsAdded; // Catalog is newer, and has added fields. No Break. Catalog has fields that won't be used by the plugin. var pluginHasNewFields = catalogFieldsAdded < pluginFieldsAdded; // Catalog is older. May break. Plugin may be expecting certain fields. if (pluginHasNewFields) { SuperController.LogMessage($"WARNING: The catalog you are opening is older and may not contain all neccessary fields (catalog version: {catalogDeapVersion}, your version: {CATALOG_DEAP_VERSION})."); } } foreach (var pluginMessage in pluginMessages) { if (MessageApplies(pluginMessage)) { SuperController.LogMessage(pluginMessage.LongMessage); return(pluginMessage); } } return(null); }
public void Copy() { try { if (!CanEdit()) { return; } var time = clipTime; var entry = AtomAnimationClip.Copy(time, GetAllOrSelectedTargets().ToList()); if (entry.empty) { SuperController.LogMessage("Timeline: Nothing to copy"); } else { clipboard.Clear(); clipboard.time = time; clipboard.entries.Add(entry); } } catch (Exception exc) { SuperController.LogError($"Timeline.{nameof(AtomAnimationEditContext)}.{nameof(Copy)}: {exc}"); } }
protected void SetDiffColor(JSONStorableColor jcolor) { foreach (Material vamMaterial in vamMaterials.SelectMany(x => x).Where(x => x != null)) { SuperController.LogMessage($"Setcolor {vamMaterial} from {vamMaterial.GetColor("_Color")} to {jcolor.colorPicker.currentColor}"); vamMaterial.SetColor("_Color", jcolor.colorPicker.currentColor); } }
public static void DebugLog(string condition, string stackTrace, LogType type) { if (condition == null || condition.StartsWith("Log ") || string.IsNullOrEmpty(stackTrace)) { return; } SuperController.LogMessage(type + " " + condition + " " + stackTrace); }
public void LoadEmbeddedInput(bool clear = true) { string[] s = pluginLabelJSON.val.Split('/'); SuperController.LogMessage(s[0] + "/" + s[1]); folderpath.val = '~' + pluginLabelJSON.val; AddEmbeddedClips(s[0], s[1], clear); // playNext.name = "PlayNext " + s[0]; }
void LoadSaveJson(JSONNode aJson) { string receiver; if (_loadReceiver.val) { receiver = aJson["receiver"].Value; } else { receiver = _receiverJSON.val; } SyncAtom(_atom.name); _receiverJSON.val = receiver; // sync receiver foreach (JSONNode target in aJson["targets"].AsArray) { string targetId = target["id"].Value; var randomizer = GetRandomizerById(targetId); if (randomizer != null) { randomizer.RestoreFromJson(target); } else { if (_addAnimatable.val && receiver == "geometry") { // Ensure target is animatable JSONStorable geometry = containingAtom.GetStorableByID("geometry"); DAZCharacterSelector character = geometry as DAZCharacterSelector; GenerateDAZMorphsControlUI morphControl = character.morphsControlUI; DAZMorph morph = morphControl.GetMorphByDisplayName(targetId); if (morph != null) { morph.animatable = true; // Add the newly-animatable target to the list and try again SyncTargetChoices(); randomizer = GetRandomizerById(targetId); if (null != randomizer) { randomizer.RestoreFromJson(target); } } } // Still no randomizer? Report the missing param if (randomizer == null) { SuperController.LogMessage("Failed to add randomizer for " + targetId); } } } SyncTargetChoices(); SyncTargets(_targetJson.val); UpdateEnabledList(); }
public static JSONClass GetJSON(IConfigProvider provider) { var config = new JSONClass(); provider.StoreConfig(config); SuperController.LogMessage("Saved config to json!"); return(config); }
private void StopSerial() { if (_serial?.IsOpen == true) { _serial.Close(); _serial = null; SuperController.LogMessage("Serial connection stopped"); } }
public override void Init() { _actionBindingExampleJSON = new JSONStorableAction( "my-action-binding", () => SuperController.LogMessage($"Hi from {containingAtom.name}!") ); SuperController.singleton.BroadcastMessage("OnActionsProviderAvailable", this, SendMessageOptions.DontRequireReceiver); }
// IMPORTANT - DO NOT OVERRIDE Awake() as it is used internally by MVRScript - instead use Init() function which // is called right after creation public override void Init() { try { // put init code in here SuperController.LogMessage("ShowSelectedControllerHUD Loaded"); // create custom JSON storable params here if you want them to be stored with scene JSON // types are JSONStorableFloat, JSONStorableBool, JSONStorableString, JSONStorableStringChooser // JSONStorableColor GameObject g = new GameObject(); dynCanvas = g.AddComponent <Canvas>(); dynCanvas.renderMode = RenderMode.WorldSpace; // only use AddCanvas if you want to interact with the UI - no needed if display only SuperController.singleton.AddCanvas(dynCanvas); CanvasScaler cs = g.AddComponent <CanvasScaler>(); cs.scaleFactor = 100.0f; cs.dynamicPixelsPerUnit = 1f; GraphicRaycaster gr = g.AddComponent <GraphicRaycaster>(); RectTransform rt = g.GetComponent <RectTransform>(); rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 500f); rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 100f); g.transform.localScale = new Vector3(0.0006f, 0.0006f, 0.0006f); g.transform.localPosition = new Vector3(.15f, .2f, .7f); // anchor to head for HUD effect Transform headCenter = SuperController.singleton.centerCameraTarget.transform; rt.SetParent(headCenter, false); //dynCanvas.transform.SetParent(headCenter, false); GameObject g2 = new GameObject(); g2.name = "Text"; g2.transform.parent = g.transform; g2.transform.localScale = Vector3.one; g2.transform.localPosition = Vector3.zero; g2.transform.localRotation = Quaternion.identity; Text t = g2.AddComponent <Text>(); RectTransform rt2 = g2.GetComponent <RectTransform>(); rt2.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 500f); rt2.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 100f); t.alignment = TextAnchor.MiddleCenter; t.horizontalOverflow = HorizontalWrapMode.Overflow; t.verticalOverflow = VerticalWrapMode.Overflow; Font ArialFont = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf"); t.font = ArialFont; t.fontSize = 24; t.text = "Test"; t.enabled = true; t.color = Color.white; dynText = t; g.name = "Canvas"; } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } }
// ReSharper disable once UnusedMember.Global public void Debug(KeyMapTreeNode node, int indent = 0) { var indentStr = new string(' ', indent); SuperController.LogMessage($"{indentStr}- {node}"); foreach (var child in node.next) { Debug(child, indent + 2); } }
public void OnDestroy() { try { SuperController.LogMessage($"{nameof(MyPlugin)} destroyed"); } catch (Exception e) { SuperController.LogError($"{nameof(MyPlugin)}.{nameof(Init)}: {e}"); } }