示例#1
0
        public void CombinedUpdate()
        {
            if (!Data)
            {
                return;
            }

            Data.RemoteUpdate();

            List <PlaytimePainter> l = PlaytimePainter.playbackPainters;

            if ((l.Count > 0) && (!StrokeVector.PausePlayback))
            {
                if (l.Last() == null)
                {
                    l.RemoveLast(1);
                }
                else
                {
                    l.Last().PlaybeckVectors();
                }
            }

            PlaytimeToolComponent.CheckRefocus();

            if (Data && (Data.disableNonMeshColliderInPlayMode) && (Application.isPlaying))
            {
                RaycastHit hit;
                if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
                {
                    Collider c = hit.collider;
                    if ((c.GetType() != typeof(MeshCollider)) && (PlaytimeToolComponent.PainterCanEditWithTag(c.tag)))
                    {
                        c.enabled = false;
                    }
                }
            }

            PlaytimePainter p = PlaytimePainter.currently_Painted_Object;

            if ((p != null) && (Application.isPlaying == false))
            {
                if ((p.ImgData == null))
                {
                    PlaytimePainter.currently_Painted_Object = null;
                }
                else
                {
                    TexMGMTdata.brushConfig.Paint(p.stroke, p);
                    p.Update();
                }
            }
        }
示例#2
0
        private void OnDisable()
        {
            PainterStuff.applicationIsQuitting = true;

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

            if (PlaytimePainter.IsCurrent_Tool())
            {
                PlaytimeToolComponent.SetPrefs();
            }

#if UNITY_EDITOR
            BeforeClosing();
#endif

#if UNITY_EDITOR
            EditorApplication.update -= meshManager.EditingUpdate;
#endif
        }
示例#3
0
        // *******************  Component MGMT
        private void OnEnable()
        {
            PainterStuff.applicationIsQuitting = false;

            Inst = this;

            if (!Data)
            {
                dataHolder = Resources.Load("Painter_Data") as PainterDataAndConfig;
            }

            if (meshManager == null)
            {
                meshManager = new MeshManager();
            }

            meshManager.OnEnable();

            if (Data)
            {
                rtcam.cullingMask = 1 << Data.myLayer;
            }

            if (PlaytimeToolComponent.enabledTool == null)
            {
                if (!Application.isEditor)
                {
#if BUILD_WITH_PAINTER
                    PlaytimeToolComponent.enabledTool = typeof(PlaytimePainter);
#else
                    PlaytimeToolComponent.GetPrefs();
#endif
                }
                else
                {
                    PlaytimeToolComponent.GetPrefs();
                }
            }
#if UNITY_EDITOR
            EditorSceneManager.sceneSaving -= BeforeSceneSaved;
            EditorSceneManager.sceneSaving += BeforeSceneSaved;
            // Debug.Log("Adding scene saving delegate");
            EditorSceneManager.sceneOpening -= OnSceneOpening;
            EditorSceneManager.sceneOpening += OnSceneOpening;

            if (defaultMaterial == null)
            {
                defaultMaterial = AssetDatabase.GetBuiltinExtraResource <Material>("Default-Material.mat");
            }

            if (defaultMaterial == null)
            {
                Debug.Log("Default Material not found.");
            }

            isLinearColorSpace = UnityEditor.PlayerSettings.colorSpace == ColorSpace.Linear;

            EditorApplication.update -= CombinedUpdate;
            if (!this.ApplicationIsAboutToEnterPlayMode())
            {
                EditorApplication.update += CombinedUpdate;
            }


            if (brushPrefab == null)
            {
                GameObject go = Resources.Load("prefabs/RenderCameraBrush") as GameObject;
                brushPrefab = go.GetComponent <RenderBrush>();
                if (brushPrefab == null)
                {
                    Debug.Log("Couldn't find brush prefab.");
                }
            }

            if (Data)
            {
                UnityHelperFunctions.RenamingLayer(Data.myLayer, "Painter Layer");
            }
#endif

            if (brushRendy == null)
            {
                brushRendy = GetComponentInChildren <RenderBrush>();
                if (brushRendy == null)
                {
                    brushRendy = Instantiate(brushPrefab.gameObject).GetComponent <RenderBrush>();
                    brushRendy.transform.parent = this.transform;
                }
            }
            if (Data)
            {
                brushRendy.gameObject.layer = Data.myLayer;
            }

#if BUILD_WITH_PAINTER || UNITY_EDITOR
            transform.position = Vector3.up * 3000;
            if (rtcam == null)
            {
                rtcam = GetComponent <Camera>();
                if (rtcam == null)
                {
                    rtcam = gameObject.AddComponent <Camera>();
                }
            }

            rtcam.orthographic     = true;
            rtcam.orthographicSize = orthoSize;
            rtcam.clearFlags       = CameraClearFlags.Nothing;
            rtcam.enabled          = Application.isPlaying;

#if UNITY_EDITOR
            EditorApplication.update -= CombinedUpdate;
            if (EditorApplication.isPlayingOrWillChangePlaymode == false)
            {
                EditorApplication.update += CombinedUpdate;
            }
#endif

            UpdateBuffersState();
#endif

            autodisabledBufferTarget = null;

            RefreshPlugins();
        }