Beispiel #1
0
        public override bool Decode(string tg, string data)
        {
            switch (tg)
            {
            case "pl":
                data.Decode_List(out PainterSystemManagerModuleBase.modules, ref _modulesMeta, PainterSystemManagerModuleBase.all);
                PainterSystemManagerModuleBase.RefreshPlugins();
                break;

            case "mm": MeshManager.Decode(data); break;

            case "rts": RenderTextureBuffersManager.renderBuffersSize = data.ToInt(); break;

            default: return(false);
            }

            return(true);
        }
Beispiel #2
0
        public bool ModulsInspect()
        {
            var changed = false;

            _modulesMeta.edit_List(ref PainterSystemManagerModuleBase.modules, PainterSystemManagerModuleBase.all).changes(ref changed);

            if (!_modulesMeta.Inspecting)
            {
                if ("Find Modules".Click())
                {
                    PainterSystemManagerModuleBase.RefreshPlugins();
                }

                if ("Delete Modules".Click().nl())
                {
                    PainterSystemManagerModuleBase.modules = null;
                }
            }

            return(changed);
        }
Beispiel #3
0
        public void CombinedUpdate()
        {
            if (!this || !Data)
            {
                return;
            }

            if (PlaytimePainter.IsCurrentTool && focusedPainter)
            {
                focusedPainter.ManagedUpdate();
            }

            if (GlobalBrush.previewDirty)
            {
                SHADER_BRUSH_UPDATE();
            }

            PlaytimePainter uiPainter = null;

            MeshManager.CombinedUpdate();

            if (!Application.isPlaying && depthProjectorCamera)
            {
                depthProjectorCamera.ManagedUpdate();
            }

#if UNITY_2018_1_OR_NEWER
            foreach (var j in blitJobsActive)
            {
                if (j.jobHandle.IsCompleted)
                {
                    j.CompleteJob();
                }
            }
#endif

            var l = PlaytimePainter.PlaybackPainters;

            if (l.Count > 0 && !StrokeVector.pausePlayback)
            {
                if (!l.Last())
                {
                    l.RemoveLast(1);
                }
                else
                {
                    l.Last().PlaybackVectors();
                }
            }

#if UNITY_EDITOR
            if (refocusOnThis)
            {
                _scipFrames--;
                if (_scipFrames == 0)
                {
                    UnityUtils.FocusOn(refocusOnThis);
                    refocusOnThis = null;
                    _scipFrames   = 3;
                }
            }
#endif

            if (!uiPainter || !uiPainter.CanPaint())
            {
                var p = PlaytimePainter.currentlyPaintedObjectPainter;

                if (p && !Application.isPlaying && sinceLastPainterCall > 0.016f)
                {
                    if (p.ImgMeta == null)
                    {
                        PlaytimePainter.currentlyPaintedObjectPainter = null;
                    }
                    else
                    {
                        TexMgmtData.brushConfig.Paint(p.stroke, p);
                        p.ManagedUpdate();
                    }
                }
            }

            var needRefresh = false;
            if (PainterSystemManagerModuleBase.modules != null)
            {
                foreach (var pl in PainterSystemManagerModuleBase.modules)
                {
                    if (pl != null)
                    {
                        pl.Update();
                    }
                    else
                    {
                        needRefresh = true;
                    }
                }
            }

            if (needRefresh)
            {
                Debug.Log("Refreshing modules");
                PainterSystemManagerModuleBase.RefreshPlugins();
            }

            sinceLastPainterCall += Time.deltaTime;
        }
Beispiel #4
0
        private 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;

            EditorSceneManager.sceneOpening -= OnSceneOpening;
            EditorSceneManager.sceneOpening += OnSceneOpening;

            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 (!UnityUtils.ApplicationIsAboutToEnterPlayMode())
            {
                EditorApplication.update += CombinedUpdate;
            }


            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).GetComponent <RenderBrush>();
                    brushRenderer.transform.parent = transform;
                }
            }



            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                = 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;

            PainterSystemManagerModuleBase.RefreshPlugins();

            foreach (var p in PainterSystemManagerModuleBase.modules)
            {
                p?.Enable();
            }

            if (Data)
            {
                Data.ManagedOnEnable();
            }

            UpdateCullingMask();
        }