private void UpdateCullingMask() { var l = (Data ? Data.playtimePainterLayer : 30); var flag = (1 << l); if (_mainCamera) { _mainCamera.cullingMask &= ~flag; } if (painterCamera) { painterCamera.cullingMask = flag; } QcUnity.RenamingLayer(l, "Playtime Painter's Layer"); if (brushRenderer) { brushRenderer.gameObject.layer = l; } #if UNITY_EDITOR var vis = Tools.visibleLayers & flag; if (vis > 0) { Debug.Log("Editor, hiding Layer {0}".F(l)); Tools.visibleLayers &= ~flag; } #endif }
public override bool Inspect(Material mat) { var changed = pegi.toggleDefaultInspector(); mat.edit(Softness, "Softness", 0, 1).nl(ref changed); mat.edit(Outline).nl(ref changed); if (mat.IsKeywordEnabled(RoundedGraphic.UNLINKED_VERTICES)) { "UNLINKED VERTICES".nl(); } var go = QcUnity.GetFocusedGameObject(); if (go) { var rndd = go.GetComponent <RoundedGraphic>(); if (!rndd) { "No RoundedGrahic.cs detected, shader needs custom data.".writeWarning(); } else if (!rndd.enabled) { "Controller is disabled".writeWarning(); } } return(changed); }
public bool Inspect() { var changed = false; if (pegi.FullWindowService.DocumentationClick("About Water Controller")) { pegi.FullWindowService.DocumentationOpen("This water works only with Merging Terrain shaders. The method is as follows: {0}" + "Terrain shaders compare it's Y(up) position with water height and calculate where the foam should be." + "THos shaders paint foam onto themselves. Below the foam they pain screen alpha channel 1, and above - 0." + "Water just renders the plane, but multiplies it by screen's alpha rendered by underlying objects. " + "This is one of those methods I labeled as EXPERIMENTAL in the Asset description. And it will probably will stay in that category" + "since it is not a robust method. And I only recommend working on those method at the later stages of your project, " + "when you can be sure it will not conflict with other effects."); } "Bump".edit(70, ref waterBump).nl(ref changed); "Wet Area Height:".edit(50, ref wetAreaHeight, 0.1f, 10).nl(ref changed); if (changed) { SetFoamDynamics(); QcUnity.RepaintViews(); this.SetToDirty(); } return(changed); }
void ReturnResults() { if (userToGetUpdate != null) { //Debug.Log("Returning user "+userToGetUpdate.ToString()); try { userToGetUpdate.AfterCameraRender(_projectorCamera.targetTexture); } catch (Exception ex) { Debug.LogError(ex); } lastUserUpdateReturned = QcUnity.TimeSinceStartup(); //if (userToGetUpdate as VolumeRayTrace != null) //Debug.Log("Returning result"); userToGetUpdate = null; if (!pauseAutoUpdates) { painterProjectorCameraConfiguration.To(_projectorCamera); } } }
protected override bool Inspect() { var changed = false; var depthCamera = DepthProjectorCamera.Instance; if (!depthCamera) { "Projector brush needs Projector Camera to be in the scene".writeWarning(); pegi.nl(); if ("Create Projector Camera".Click().nl()) { QcUnity.Instantiate <DepthProjectorCamera>(); } } else { "Projector:".nl(); #if UNITY_EDITOR if (Application.isPlaying && EditorApplication.isPaused && depthCamera._projectFromMainCamera) { "In Play mode Projector brush is copying position from main camera".writeHint(); } #endif if (Brush.showAdvanced) { "Paint only visible (by Projector)".toggleIcon(ref Cfg.useDepthForProjector).nl(); } var painter = PlaytimePainter.inspected; bool mentionLink = !depthCamera._projectFromMainCamera; bool mentionPrview = painter && painter.NotUsingPreview; if (mentionLink || mentionPrview) { "{0} {1}".F(mentionLink ? "You can Lock Projector to current camera view to allign the projection." + Environment.NewLine : "", mentionPrview ? "Preview helps see the Projection" : "").writeHint(); } if (icon.Delete.Click("Delete Projector Camera")) { depthCamera.gameObject.DestroyWhatever(); } else { pegi.Nested_Inspect(depthCamera.Inspect_PainterShortcut).nl(ref changed); } pegi.line(Color.black); pegi.nl(); } base.Inspect().nl(ref changed); return(changed); }
private CfgEncoder Add <T>(T val, IList <Type> types, ListMetaData ld, int index) where T : ICfg { var el = ld.elementDatas.GetIfExists(index); if (!QcUnity.IsNullOrDestroyed_Obj(val)) { var typeIndex = types.IndexOf(val.GetType()); if (typeIndex != -1) { el?.SetRecognized(); Add(typeIndex.ToString(), val.Encode()); } else { el = ld.elementDatas[index]; el.unrecognized = true; el.stdDta = val.Encode().ToString(); Add_String(UnrecognizedTag, " "); } } else { if (el != null && el.unrecognized) { Add_String(el.unrecognizedUnderTag, el.stdDta); } else { Add_String(NullTag, ""); } } return(this); }
void ReturnResults() { if (userToGetUpdate != null) { try { if (!QcUnity.IsNullOrDestroyed_Obj(userToGetUpdate)) { userToGetUpdate.AfterCameraRender(_projectorCamera.targetTexture); } } catch (Exception ex) { Debug.LogError(ex); } lastUserUpdateReturned = QcUnity.TimeSinceStartup(); userToGetUpdate = null; if (!pauseAutoUpdates) { painterProjectorCameraConfiguration.To(_projectorCamera); } } }
public static void UnlockInspectorWindowIfLocked(GameObject go) { #if UNITY_EDITOR if (ActiveEditorTracker.sharedTracker.isLocked) { if (!Selection.objects.IsNullOrEmpty()) { var match = false; foreach (var o in Selection.objects) { if (o == go) { match = true; break; } } if (!match) { return; } } ActiveEditorTracker.sharedTracker.isLocked = false; QcUnity.FocusOn(go); } #endif }
public static bool ClickDuplicate <T>(ref T obj, string folder, string extension, string newName = null) where T : Object { if (!obj) { return(false); } var changed = false; #if UNITY_EDITOR var path = AssetDatabase.GetAssetPath(obj); if (icon.Copy.ClickConfirm("dpl" + obj + "|" + path, "{0} Duplicate at {1}".F(obj, path)).changes(ref changed)) { obj = QcUnity.Duplicate(obj, folder, extension: extension, newName: newName); } #else if (icon.Copy.Click("Create Instance of {0}".F(obj))) { obj = GameObject.Instantiate(obj); } #endif return(changed); }
public bool TryGetByGuid <T>(ref T field) where T : Object { var obj = QcUnity.GuidToAsset <T>(_guid); field = null; if (!obj) { return(false); } field = obj; if (componentType.IsNullOrEmpty()) { return(true); } var go = obj as GameObject; if (!go) { return(true); } var getScripts = go.GetComponent(componentType) as T; if (getScripts) { field = getScripts; } return(true); }
public virtual bool Inspect() { var changed = false; "Profile Name: ".editDelayed(80, ref name); #if UNITY_EDITOR var path = Path.Combine(PainterCamera.Data.meshesFolderName, FolderName); if (icon.Save.Click("Save To:" + path, 25).nl()) { this.SaveToAssets(path, name); QcUnity.RefreshAssetDatabase(); pegi.GameView.ShowNotification(name + " Saved to " + path); } #endif foreach (var s in dtaLnks) { s.Inspect().nl(ref changed); } return(changed); }
public static bool Inspect <T>(ref T configs) where T : ConfigurationsListBase { var changed = false; if (configs) { if (icon.UnLinked.Click("Disconnect config")) { configs = null; } else { configs.Nested_Inspect().nl(ref changed); } } else { "Configs".edit(90, ref configs); if (icon.Create.Click("Create new Config")) { configs = QcUnity.CreateScriptableObjectAsset <T>("ScriptableObjects/Configs", "Config"); } pegi.nl(); } return(changed); }
public CfgEncoder Add(string tag, ICfg other) { if (QcUnity.IsNullOrDestroyed_Obj(other)) { return(this); } var safe = other as ICfgSafeEncoding; if (safe == null) { return(Add(tag, other.Encode())); } var ll = safe.GetLoopLock; if (ll.Unlocked) { using (ll.Lock()) { Add(tag, other.Encode()); } } else { Debug.LogError("Infinite encoding loop detected"); } return(this); }
public static bool SendReceivePegi(this ICfg cfg, string name, string folderName, out string data) { if (icon.Email.Click("Send {0} to somebody via email.".F(folderName))) { cfg.EmailData(name, "Use this {0}".F(name)); } data = ""; if (pegi.edit(ref data).UnFocusIfTrue()) { data = ClearFromExternal(data); return(true); } if (icon.Folder.Click("Save {0} to the file".F(name))) { cfg.SaveToAssets(folderName, name); QcUnity.RefreshAssetDatabase(); } if (DropStringObject(out data)) { return(true); } pegi.nl(); return(false); }
public static void TryCopy_Std_AndOtherData(object from, object into) { if (into == null || into == from) { return; } var intoStd = into as ICfg; if (intoStd != null) { var fromStd = from as ICfg; if (fromStd != null) { var prev = CfgEncoder.keeper; CfgEncoder.keeper = TmpHolder; intoStd.Decode(fromStd.Encode().ToString()); CfgEncoder.keeper = prev; TmpHolder.nestedReferences.Clear(); } } var ch = into as ICanChangeClass; if (ch != null && !QcUnity.IsNullOrDestroyed_Obj(from)) { ch.OnClassTypeChange(from); } }
public bool InspectInList(IList list, int ind, ref int edited) { var changed = false; Texture tex; TryGetTexture(out tex); #if QC_USE_NETWORKING if (_request != null) { "Loading".write(60); } if (_failed) { "Failed".write(50); } if (_texture) { if (icon.Refresh.Click()) { Start(); } if (_texture.Click()) { edited = ind; } } else { if (_failed) { if (icon.Refresh.Click("Failed")) { Start(); } "Failed ".F(_url).write(40); } else { icon.Active.write(); "Loading ".write(40); } } #else "QC_USE_NETWORKING is disabled (to prevent unwanted android permissions)".writeWarning(); pegi.nl(); if ("Enable QC_USE_NETWORKING".Click()) { QcUnity.SetPlatformDirective("QC_USE_NETWORKING", true); } #endif _url.write(); return(changed); }
private static object SetToDirty_Obj(this object obj) { #if UNITY_EDITOR QcUnity.SetToDirty(obj as UnityEngine.Object); #endif return(obj); }
public CfgEncoder Add(string tag, ICfg other) { if (QcUnity.IsNullOrDestroyed_Obj(other)) { return(this); } return(Add(tag, other.Encode())); }
static void AfterBlit(Texture target) { if (target && target.IsBigRenderTexturePair()) { secondBufferUpdated = false; } PainterCamera.lastPainterCall = QcUnity.TimeSinceStartup(); }
public static int RealTimeNow() { if (_realTimeOnStartUp == 0) { _realTimeOnStartUp = (int)((DateTime.Now.Ticks - 733000 * TimeSpan.TicksPerDay) / TimeSpan.TicksPerSecond); } return(_realTimeOnStartUp + (int)QcUnity.TimeSinceStartup()); }
public static void TryReplaceAssetByGuid <T>(this string data, ref T val) where T : UnityEngine.Object { var ass = QcUnity.GuidToAsset <T>(data); if (ass) { val = ass; } }
public override CfgEncoder Encode() { if (_encodeDecodeLock.Unlocked) { using (_encodeDecodeLock.Lock()) { for (var i = 0; i < imgMetas.Count; i++) { var id = imgMetas[i]; if (id != null && id.NeedsToBeSaved) { continue; } imgMetas.RemoveAt(i); i--; } for (var index = 0; index < matMetas.Count; index++) { var md = matMetas[index]; if (QcUnity.SavedAsAsset(md.material)) { continue; } matMetas.Remove(md); index--; } var cody = this.EncodeUnrecognized() .Add("imgs", imgMetas, this) .Add("sch", selectedColorScheme) .Add("mats", matMetas, this) .Add("pals", colorSchemes) .Add("cam", PainterCamera.Inst) .Add("Vpck", meshPackagingSolutions) .Add_IfTrue("hd", hideDocumentation) .Add_IfNotNegative("iid", _inspectedImgData) .Add_IfNotNegative("isfs", _inspectedItems) .Add_IfNotNegative("im", _inspectedMaterial) .Add_IfNotNegative("id", _inspectedDecal) .Add_IfNotNegative("is", inspectedItems) .Add_IfTrue("e", toolEnabled); return(cody); } } else { Debug.LogError("Loop in Encoding"); } return(null); }
public static void UpdateCfgPrefab(this ICfg s, GameObject go) { var iK = s as IKeepMyCfg; if (iK != null) { iK.SaveCfgData(); } QcUnity.UpdatePrefab(go); }
public static void EmailData(this ICfg cfg, string subject, string note) { if (cfg == null) { return; } QcUnity.SendEmail("*****@*****.**", subject, "{0} {1} Copy this entire email and paste it in the corresponding field on your side to paste it (don't change data before pasting it). {2} {3}{4}{5}".F(note, pegi.EnvironmentNl, pegi.EnvironmentNl, StdStart, cfg.Encode().ToString(), StdEnd)); }
public static void RefocusIfLocked(Object current, Object target) { #if UNITY_EDITOR if (current != target && target && ActiveEditorTracker.sharedTracker.isLocked) { ActiveEditorTracker.sharedTracker.isLocked = false; QcUnity.FocusOn(target); ActiveEditorTracker.sharedTracker.isLocked = true; } #endif }
public void Log_Interval(float seconds, string msg = null, bool asError = true, Object obj = null) { if (!_logged || (QcUnity.TimeSinceStartup() - _lastLogged > seconds)) { Log_Now(msg, asError, obj); } else { _calls++; } }
public CfgEncoder Add <T>(T v, List <Type> types) where T : ICfg { if (QcUnity.IsNullOrDestroyed_Obj(v)) { return(Add_String(NullTag, "")); } var typeIndex = types.IndexOf(v.GetType()); return(Add(typeIndex != -1 ? typeIndex.ToString() : UnrecognizedTag, v.Encode())); }
public Base SetKeyword(TextureMeta id) { foreach (var bs in AllModes) { QcUnity.SetShaderKeyword(bs.ShaderKeyword(id), false); } QcUnity.SetShaderKeyword(ShaderKeyword(id), true); return(this); }
public CfgEncoder Add_IfNotDefault(string tag, ICfg cfg) { if (QcUnity.IsNullOrDestroyed_Obj(cfg)) { return(this); } var def = cfg as ICanBeDefaultCfg; return((def == null || !def.IsDefault) ? Add(tag, cfg) : this); }
public static void ApplySelected() { if (selected == null) { selected = _allModes[0]; } foreach (MeshShaderMode s in _allModes) { QcUnity.SetShaderKeyword(s.value, selected == s); } }