Exemple #1
0
        void BakeColor(PaintJob job, BakeChannel bc, Vector4 val, int i)
        {
            switch (bc)
            {
            case BakeChannel.Color:
            {
                job.stream.colors[i] = new Color(val.x, val.y, val.z, val.w);
                break;
            }

            case BakeChannel.UV0:
            {
                job.stream.uv0[i] = val;
                break;
            }

            case BakeChannel.UV1:
            {
                job.stream.uv1[i] = val;
                break;
            }

            case BakeChannel.UV2:
            {
                job.stream.uv2[i] = val;
                break;
            }

            case BakeChannel.UV3:
            {
                job.stream.uv3[i] = val;
                break;
            }
            }
        }
 void BakeColor(PaintJob job, BakeChannel bc, Vector4 val, int i)
 {
    switch (bc)
    {
       case BakeChannel.Color:
       {
          job.stream.colors[i] = new Color(val.x, val.y, val.z, val.w); break;
       }
       case BakeChannel.UV0:
       {
          job.stream.uv0[i] = val;
          break;
       }
       case BakeChannel.UV1:
       {
          job.stream.uv1[i] = val;
          break;
       }
       case BakeChannel.UV2:
       {
          job.stream.uv2[i] = val;
          break;
       }
       case BakeChannel.UV3:
       {
          job.stream.uv3[i] = val;
          break;
       }
    }
 }
        public void OnGUI(PaintJob[] jobs)
        {
            bakingTex = EditorGUILayout.ObjectField("Texture", bakingTex, typeof(Texture2D), false) as Texture2D;

             bakeSourceUV = (BakeSourceUV)EditorGUILayout.EnumPopup("Source UVs", bakeSourceUV);
             bakeChannel = (BakeChannel)EditorGUILayout.EnumPopup("Bake To", bakeChannel);
             if (bakeSourceUV == BakeSourceUV.WorldSpaceXY || bakeSourceUV == BakeSourceUV.WorldSpaceXZ || bakeSourceUV == BakeSourceUV.WorldSpaceYZ)
             {
            worldSpaceLower = EditorGUILayout.Vector2Field("Lower world position", worldSpaceLower);
            worldSpaceUpper = EditorGUILayout.Vector2Field("Upper world position", worldSpaceUpper);
             }
             EditorGUILayout.BeginHorizontal();
             EditorGUILayout.Space();
             if (GUILayout.Button("Bake"))
             {
            if (bakingTex != null)
            {
               BakeFromTexture(jobs);
            }
            else
            {
               EditorUtility.DisplayDialog("Error", "Baking texture is not set", "ok");
            }
             }
             EditorGUILayout.Space();
             EditorGUILayout.EndHorizontal();
        }
 void InitBakeChannel(BakeChannel bc, PaintJob[] jobs)
 {
     foreach (PaintJob job in jobs)
     {
         if (bc == BakeChannel.Position)
         {
             if (job.stream.positions == null || job.stream.positions.Length != job.verts.Length)
             {
                 job.stream.positions = job.verts;
             }
         }
         if (bc == BakeChannel.Color)
         {
             if (job.stream.colors == null || job.stream.colors.Length != job.verts.Length)
             {
                 job.stream.colors = job.meshFilter.sharedMesh.colors;
             }
         }
         else if (bc == BakeChannel.UV0)
         {
             if (job.stream.uv0 == null || job.stream.uv0.Count != job.verts.Length)
             {
                 job.stream.uv0 = new List <Vector4>(job.verts.Length);
                 job.meshFilter.sharedMesh.GetUVs(0, job.stream.uv0);
             }
         }
         else if (bc == BakeChannel.UV1)
         {
             if (job.stream.uv1 == null || job.stream.uv1.Count != job.verts.Length)
             {
                 job.stream.uv1 = new List <Vector4>(job.verts.Length);
                 job.meshFilter.sharedMesh.GetUVs(0, job.stream.uv1);
             }
         }
         else if (bc == BakeChannel.UV2)
         {
             if (job.stream.uv2 == null || job.stream.uv2.Count != job.verts.Length)
             {
                 job.stream.uv2 = new List <Vector4>(job.verts.Length);
                 job.meshFilter.sharedMesh.GetUVs(0, job.stream.uv2);
             }
         }
         else if (bc == BakeChannel.UV3)
         {
             if (job.stream.uv3 == null || job.stream.uv3.Count != job.verts.Length)
             {
                 job.stream.uv3 = new List <Vector4>(job.verts.Length);
                 job.meshFilter.sharedMesh.GetUVs(0, job.stream.uv3);
             }
         }
         EditorUtility.SetDirty(job.stream);
         EditorUtility.SetDirty(job.stream.gameObject);
     }
 }
 public void OnGUI(PaintJob[] jobs)
 {
     EditorGUILayout.HelpBox("Multiply a channel by a value. Useful for scaling UVs, objects, etc", MessageType.Info);
      bakeChannel = (BakeChannel)EditorGUILayout.EnumPopup("Channel", bakeChannel);
      multValue = EditorGUILayout.FloatField("Multiply By", multValue);
      EditorGUILayout.BeginHorizontal();
      EditorGUILayout.Space();
      if (GUILayout.Button("Multiply It"))
      {
     Bake(jobs);
      }
      EditorGUILayout.Space();
      EditorGUILayout.EndHorizontal();
 }
Exemple #6
0
 void InitBakeChannel(BakeChannel bc, PaintJob[] jobs)
 {
     foreach (PaintJob job in jobs)
     {
         if (bc == BakeChannel.Color)
         {
             if (job.stream.colors == null || job.stream.colors.Length != job.verts.Length)
             {
                 job.stream.SetColor(Color.black, job.verts.Length);
             }
         }
         else if (bc == BakeChannel.UV0)
         {
             if (job.stream.uv0 == null || job.stream.uv0.Count != job.verts.Length)
             {
                 job.stream.SetUV0(Vector4.zero, job.verts.Length);
             }
         }
         else if (bc == BakeChannel.UV1)
         {
             if (job.stream.uv1 == null || job.stream.uv1.Count != job.verts.Length)
             {
                 job.stream.SetUV1(Vector4.zero, job.verts.Length);
             }
         }
         else if (bc == BakeChannel.UV2)
         {
             if (job.stream.uv2 == null || job.stream.uv2.Count != job.verts.Length)
             {
                 job.stream.SetUV2(Vector4.zero, job.verts.Length);
             }
         }
         else if (bc == BakeChannel.UV3)
         {
             if (job.stream.uv3 == null || job.stream.uv3.Count != job.verts.Length)
             {
                 job.stream.SetUV3(Vector4.zero, job.verts.Length);
             }
         }
         EditorUtility.SetDirty(job.stream);
         EditorUtility.SetDirty(job.stream.gameObject);
     }
 }
 void InitBakeChannel(BakeChannel bc)
 {
    foreach (PaintJob job in jobs)
    {
       if (bc == BakeChannel.Color)
       {
          if (job.stream.colors == null || job.stream.colors.Length != job.verts.Length)
          {
             job.stream.SetColor(Color.black, job.verts.Length);
          }
       }
       else if (bc == BakeChannel.UV0)
       {
          if (job.stream.uv0 == null || job.stream.uv0.Count!= job.verts.Length)
          {
             job.stream.SetUV0(Vector4.zero, job.verts.Length);
          }
       }
       else if (bc == BakeChannel.UV1)
       {
          if (job.stream.uv1 == null || job.stream.uv1.Count != job.verts.Length)
          {
             job.stream.SetUV1(Vector4.zero, job.verts.Length);
          }
       }
       else if (bc == BakeChannel.UV2)
       {
          if (job.stream.uv2 == null || job.stream.uv2.Count != job.verts.Length)
          {
             job.stream.SetUV2(Vector4.zero, job.verts.Length);
          }
       }
       else if (bc == BakeChannel.UV3)
       {
          if (job.stream.uv3 == null || job.stream.uv3.Count != job.verts.Length)
          {
             job.stream.SetUV3(Vector4.zero, job.verts.Length);
          }
       }
       EditorUtility.SetDirty(job.stream);
       EditorUtility.SetDirty(job.stream.gameObject);
    }
 }
 void InitBakeChannel(BakeChannel bc, PaintJob[] jobs)
 {
     foreach (PaintJob job in jobs)
      {
     if (bc == BakeChannel.Position)
     {
        if (job.stream.positions == null || job.stream.positions.Length != job.verts.Length)
        {
           job.stream.positions = job.verts;
        }
     }
     if (bc == BakeChannel.Color)
     {
        if (job.stream.colors == null || job.stream.colors.Length != job.verts.Length)
        {
           job.stream.colors = job.meshFilter.sharedMesh.colors;
        }
     }
     else if (bc == BakeChannel.UV0)
     {
        if (job.stream.uv0 == null || job.stream.uv0.Count!= job.verts.Length)
        {
           job.stream.uv0 = new List<Vector4>(job.verts.Length);
           job.meshFilter.sharedMesh.GetUVs(0, job.stream.uv0);
        }
     }
     else if (bc == BakeChannel.UV1)
     {
        if (job.stream.uv1 == null || job.stream.uv1.Count != job.verts.Length)
        {
           job.stream.uv1 = new List<Vector4>(job.verts.Length);
           job.meshFilter.sharedMesh.GetUVs(0, job.stream.uv1);
        }
     }
     else if (bc == BakeChannel.UV2)
     {
        if (job.stream.uv2 == null || job.stream.uv2.Count != job.verts.Length)
        {
           job.stream.uv2 = new List<Vector4>(job.verts.Length);
           job.meshFilter.sharedMesh.GetUVs(0, job.stream.uv2);
        }
     }
     else if (bc == BakeChannel.UV3)
     {
        if (job.stream.uv3 == null || job.stream.uv3.Count != job.verts.Length)
        {
           job.stream.uv3 = new List<Vector4>(job.verts.Length);
           job.meshFilter.sharedMesh.GetUVs(0, job.stream.uv3);
        }
     }
     EditorUtility.SetDirty(job.stream);
     EditorUtility.SetDirty(job.stream.gameObject);
      }
 }