public override bool Decode(string tg, string data) { switch (tg) { case "pl": data.Decode_List(out CameraModuleBase.modules, ref _modulesMeta, CameraModuleBase.all); CameraModuleBase.RefreshPlugins(); break; case "mm": MeshManager.Decode(data); break; case "rts": RenderTextureBuffersManager.renderBuffersSize = data.ToInt(); break; default: return(false); } return(true); }
public bool ModulsInspect() { var changed = false; _modulesMeta.edit_List(ref CameraModuleBase.modules, CameraModuleBase.all).changes(ref changed); if (!_modulesMeta.Inspecting) { if ("Find Modules".Click()) { CameraModuleBase.RefreshPlugins(); } if ("Delete Modules".Click().nl()) { CameraModuleBase.modules = null; } } return(changed); }
public void CombinedUpdate() { if (!this || !Data) { return; } lastManagedUpdate = Time.time; if (PlaytimePainter.IsCurrentTool && focusedPainter) { focusedPainter.ManagedUpdateOnFocused(); } if (GlobalBrush.previewDirty) { SHADER_BRUSH_UPDATE(); } QcAsync.UpdateManagedCoroutines(); MeshManager.CombinedUpdate(); if (!Application.isPlaying && depthProjectorCamera) { depthProjectorCamera.ManagedUpdate(); } #if UNITY_EDITOR if (refocusOnThis) { _scipFrames--; if (_scipFrames == 0) { QcUnity.FocusOn(refocusOnThis); refocusOnThis = null; _scipFrames = 3; } } #endif var p = PlaytimePainter.currentlyPaintedObjectPainter; if (p && !Application.isPlaying && ((Time.time - lastPainterCall) > 0.016f)) { if (p.TexMeta == null) { PlaytimePainter.currentlyPaintedObjectPainter = null; } else { p.ProcessStrokeState(); //TexMgmtData.brushConfig.Paint(p.stroke, p); //p.ManagedUpdateOnFocused(); } } var needRefresh = false; if (CameraModuleBase.modules != null) { foreach (var pl in CameraModuleBase.modules) { if (pl != null) { pl.Update(); } else { needRefresh = true; } } } if (needRefresh) { Debug.Log("Refreshing modules"); CameraModuleBase.RefreshPlugins(); } lastPainterCall = Time.time; }
public void OnEnable() { if (!MainCamera) { MainCamera = Camera.main; } DepthProjectorCamera.triedToFindDepthCamera = false; PainterSystem.applicationIsQuitting = false; Inst = this; if (!Data) { dataHolder = Resources.Load("Painter_Data") as PainterDataAndConfig; } MeshManager.OnEnable(); if (!painterCamera) { painterCamera = GetComponent <Camera>(); } if (!PainterDataAndConfig.toolEnabled && !Application.isEditor) { PainterDataAndConfig.toolEnabled = true; } #if UNITY_EDITOR EditorSceneManager.sceneSaving -= BeforeSceneSaved; EditorSceneManager.sceneSaving += BeforeSceneSaved; if (!defaultMaterial) { defaultMaterial = AssetDatabase.GetBuiltinExtraResource <Material>("Default-Material.mat"); } if (!defaultMaterial) { Debug.Log("Default Material not found."); } IsLinearColorSpace = PlayerSettings.colorSpace == ColorSpace.Linear; EditorApplication.update -= CombinedUpdate; if (!QcUnity.ApplicationIsAboutToEnterPlayMode()) { SubscribeToEditorUpdates(); } if (!brushPrefab) { var go = Resources.Load("prefabs/RenderCameraBrush") as GameObject; if (go) { brushPrefab = go.GetComponent <RenderBrush>(); if (!brushPrefab) { Debug.Log("Couldn't find brush prefab."); } } else { Debug.LogError("Couldn't load brush Prefab"); } } #endif if (!brushRenderer) { brushRenderer = GetComponentInChildren <RenderBrush>(); if (!brushRenderer) { brushRenderer = Instantiate(brushPrefab.gameObject, transform).GetComponent <RenderBrush>(); } } transform.position = Vector3.up * 3000; transform.localScale = Vector3.one; transform.rotation = Quaternion.identity; if (!painterCamera) { painterCamera = GetComponent <Camera>(); if (!painterCamera) { painterCamera = gameObject.AddComponent <Camera>(); } } painterCamera.orthographic = true; painterCamera.orthographicSize = OrthographicSize; painterCamera.clearFlags = CameraClearFlags.Nothing; painterCamera.enabled = false; //Application.isPlaying; painterCamera.allowHDR = false; painterCamera.allowMSAA = false; painterCamera.allowDynamicResolution = false; painterCamera.depth = 0; painterCamera.renderingPath = RenderingPath.Forward; painterCamera.nearClipPlane = 0.1f; painterCamera.farClipPlane = 1000f; painterCamera.rect = Rect.MinMaxRect(0, 0, 1, 1); #if UNITY_EDITOR EditorApplication.update -= CombinedUpdate; if (EditorApplication.isPlayingOrWillChangePlaymode == false) { EditorApplication.update += CombinedUpdate; } #endif RecreateBuffersIfDestroyed(); autodisabledBufferTarget = null; CameraModuleBase.RefreshPlugins(); foreach (var p in CameraModuleBase.modules) { p?.Enable(); } if (Data) { Data.ManagedOnEnable(); } UpdateCullingMask(); PainterShaderVariables.BrushColorProperty.ConvertToLinear = IsLinearColorSpace; }
public void CombinedUpdate() { if (!this || !Data) { return; } lastManagedUpdate = QcUnity.TimeSinceStartup(); if (PlaytimePainter.IsCurrentTool && FocusedPainter) { FocusedPainter.ManagedUpdateOnFocused(); } QcAsync.UpdateManagedCoroutines(); MeshManager.CombinedUpdate(); if (!Application.isPlaying && depthProjectorCamera) { depthProjectorCamera.ManagedUpdate(); } #if UNITY_EDITOR if (refocusOnThis) { _scipFrames--; if (_scipFrames == 0) { QcUnity.FocusOn(refocusOnThis); refocusOnThis = null; _scipFrames = 3; } } #endif var p = PlaytimePainter.currentlyPaintedObjectPainter; if (p && !Application.isPlaying && ((QcUnity.TimeSinceStartup() - lastPainterCall) > 0.016f)) { if (p.TexMeta == null) { PlaytimePainter.currentlyPaintedObjectPainter = null; } else { p.ProcessStrokeState(); } } var needRefresh = false; if (CameraModuleBase.modules != null) { foreach (var pl in CameraModuleBase.modules) { if (pl != null) { pl.Update(); } else { needRefresh = true; } } } if (needRefresh) { Debug.Log("Refreshing modules"); CameraModuleBase.RefreshPlugins(); } lastPainterCall = QcUnity.TimeSinceStartup(); }