Skip to content

Commit

Permalink
Re-Check components when start painting
Browse files Browse the repository at this point in the history
  • Loading branch information
piXelicidio committed Aug 11, 2023
1 parent 5bf3fd8 commit 8b8ef70
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions Code/Editor/PolyPaintWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,16 @@ public void OnDestroy()

void StartPaintMode()
{
PrepareObject();
_paintingMode = true;
_lastPixelColor = _painter.GetTextureColor(_lastUVpick);
PaintEditor.SetPixelColor(_lastPixelColor);
SceneView.lastActiveSceneView.Repaint();
PaintEditor.PaintMode = true;
CheckComponents(_targetObject);
if (_targetTexture != null)
{
PrepareObject();
_paintingMode = true;
_lastPixelColor = _painter.GetTextureColor(_lastUVpick);
PaintEditor.SetPixelColor(_lastPixelColor);
SceneView.lastActiveSceneView.Repaint();
PaintEditor.PaintMode = true;
}
}

void StopPaintMode()
Expand Down Expand Up @@ -203,7 +207,7 @@ void OnGUI()

//Big PAINT MODE button
_scrollPos = EGL.BeginScrollView(_scrollPos);
using (new EditorGUI.DisabledScope(_targetMesh == null))
using (new EditorGUI.DisabledScope(_targetTexture == null))
{
if (!_paintingMode)
{
Expand Down Expand Up @@ -1231,7 +1235,6 @@ void OnSelectionChange()
if (_paintingMode) return;

_targetObject = Selection.activeGameObject;
_skinned = false;
if (_targetObject != null)
{
CheckComponents(_targetObject);
Expand All @@ -1247,6 +1250,7 @@ void OnSelectionChange()

private void CheckComponents(GameObject target)
{
_skinned = false;
var solid = target.GetComponent<MeshFilter>();
var skinned = target.GetComponent<SkinnedMeshRenderer>();
if (solid != null)
Expand All @@ -1266,17 +1270,14 @@ private void CheckComponents(GameObject target)
var r = target.GetComponent<Renderer>();
if (r != null)
{
_targetTexture = r.sharedMaterial.mainTexture;
_targetTexture = null;
_textureData = null;
var mat = r.sharedMaterial;
if (mat != null) _targetTexture = mat.mainTexture;
if (_targetTexture != null)
{
_textureData = ToTexture2D(_targetTexture);
}
else
{
_targetTexture = null;
_textureData = null;
}

}
else
{
Expand Down

0 comments on commit 8b8ef70

Please sign in to comment.