public static T GetModule <T>() where T : CameraModuleBase { if (CameraModuleBase.modules == null) { CameraModuleBase.RefreshModules(); } return((T)CameraModuleBase.modules.Find(m => m.GetType() == typeof(T))); }
public override void Decode(string key, CfgData data) { switch (key) { case "pl": data.ToList(out CameraModuleBase.modules, CameraModuleBase.all); CameraModuleBase.RefreshModules(); break; case "mm": MeshManager.DecodeFull(data); break; case "rts": RenderTextureBuffersManager.renderBuffersSize = data.ToInt(0); break; } }
public override bool Decode(string tg, string data) { switch (tg) { case "pl": data.Decode_List(out CameraModuleBase.modules, ref _modulesMeta, CameraModuleBase.all); CameraModuleBase.RefreshModules(); 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.RefreshModules(); } if ("Delete Modules".Click().nl()) { CameraModuleBase.modules = null; } } return(changed); }
public override bool Inspect() { pegi.toggleDefaultInspector(this).nl(); var changed = false; if ("Camera Modules".enter(ref _inspectedStuff, 0, false).nl_ifNotEntered()) { _modulesMeta.edit_List(ref CameraModuleBase.modules, CameraModuleBase.all).changes(ref changed); if (!_modulesMeta.Inspecting) { if ("Find Modules".Click()) { CameraModuleBase.RefreshModules(); } if ("Delete Modules".Click().nl()) { CameraModuleBase.modules = null; } } pegi.nl(); } if ("Depth Projector Camera".enter(ref _inspectedStuff, 1).nl()) { if (DepthProjectorCamera.Instance) { DepthProjectorCamera.Instance.Nested_Inspect().nl(); } else if ("Instantiate".Click()) { GetOrCreateProjectorCamera(); } } if ("Painter Camera".enter(ref _inspectedStuff, 2).nl_ifNotEntered()) { DependenciesInspect(true); } if ("Data && Config".enter(ref _inspectedStuff, 3).nl_ifEntered()) { if (Data) { Data.Nested_Inspect().nl(ref changed); } else { "NO CONFIG Scriptable Object".writeWarning(); pegi.nl(); DependenciesInspect(true); } } if (_inspectedStuff == -1 && Data) { Data.ClickHighlight(); } pegi.nl(); if ("Inspector & Debug".enter(ref _inspectedStuff, 4).nl()) { QcUtils.InspectInspector(); } pegi.nl(); return(changed); }
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.RefreshModules(); } lastPainterCall = QcUnity.TimeSinceStartup(); }
public void OnEnable() { if (!MainCamera) { MainCamera = Camera.main; } DepthProjectorCamera.triedToFindDepthCamera = false; PainterClass.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; IsLinearColorSpace = PlayerSettings.colorSpace == ColorSpace.Linear; EditorApplication.update -= CombinedUpdate; if (!QcUnity.ApplicationIsAboutToEnterPlayMode()) { SubscribeToEditorUpdates(); } if (!brushPrefab) { var go = Resources.Load(PainterDataAndConfig.PREFABS_RESOURCE_FOLDER + "/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 autodisabledBufferTarget = null; CameraModuleBase.RefreshModules(); foreach (var p in CameraModuleBase.modules) { p?.Enable(); } if (Data) { Data.ManagedOnEnable(); } UpdateCullingMask(); PainterShaderVariables.BrushColorProperty.ConvertToLinear = IsLinearColorSpace; }