Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Content/Shader/EdgePicker.shader
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CGPROGRAM
return o;
}

float4 frag (v2f i) : COLOR
float4 frag (v2f i) : SV_Target
{
return i.color;
}
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/FaceHighlight.shader
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Shader "Hidden/ProBuilder/FaceHighlight"
return o;
}

half4 frag (v2f i) : COLOR
half4 frag (v2f i) : SV_Target
{
i.pos.xy = floor(i.pos.xy * 1) * .5;
float checker = -frac(i.pos.x + i.pos.y);
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/FacePicker.shader
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Shader "Hidden/ProBuilder/FacePicker"
return o;
}

float4 frag (v2f i) : COLOR
float4 frag (v2f i) : SV_Target
{
return i.color;
}
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/HideVertices.shader
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Shader "Hidden/ProBuilder/HideVertices"
return o;
}

half4 frag (v2f i) : COLOR
half4 frag (v2f i) : SV_Target
{
return fixed4(0,0,0,0);
}
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/LineBillboard.shader
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Shader "Hidden/ProBuilder/LineBillboard"
triStream.Append(geo_out);
}

fixed4 frag (v2f i) : COLOR
fixed4 frag (v2f i) : SV_Target
{
return i.color * _Color;
}
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/LineBillboardMetal.shader
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Shader "Hidden/ProBuilder/LineBillboardMetal"
return o;
}

half4 frag (v2f i) : COLOR
half4 frag (v2f i) : SV_Target
{
return _Color;
}
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/NormalPreview.shader
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Shader "Hidden/ProBuilder/NormalPreview"
return o;
}

half4 frag (v2f i) : COLOR
half4 frag (v2f i) : SV_Target
{
return i.color;
}
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/PointBillboard.shader
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Shader "Hidden/ProBuilder/PointBillboard"
triStream.Append(geo_out);
}

float4 frag(FS_INPUT input) : COLOR
float4 frag(FS_INPUT input) : SV_Target
{
return _Color * input.color;
}
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/ReferenceUnlit.shader
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Shader "ProBuilder/Reference Unlit"
return o;
}

half4 frag (v2f i) : COLOR
half4 frag (v2f i) : SV_Target
{
return tex2D(_MainTex, i.uv);
}
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/ScrollHighlight.shader
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Shader "Hidden/ProBuilder/ScrollHighlight" {
o.pos = UnityObjectToClipPos(v.vertex );
return o;
}
float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
float4 frag(VertexOutput i, float facing : VFACE) : SV_Target {
float isFrontFace = ( facing >= 0 ? 1 : 0 );
float faceSign = ( facing >= 0 ? 1 : -1 );
////// Lighting:
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/SmoothingPreview.shader
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Shader "Hidden/ProBuilder/SmoothingPreview"
return o;
}

half4 frag (v2f i) : COLOR
half4 frag (v2f i) : SV_Target
{
i.pos.xy = floor(i.pos.xy * 1) * .5;
float checker = -frac(i.pos.x + i.pos.y);
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/TransparentOverlay.shader
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Shader "Hidden/ProBuilder/TransparentOverlay"
return o;
}

half4 frag (v2f i) : COLOR
half4 frag (v2f i) : SV_Target
{
return tex2D(_MainTex, i.uv) * i.color;
}
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/UnlitSolidColor.shader
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Shader "ProBuilder/Unlit Solid Color"
return o;
}

half4 frag (v2f i) : COLOR
half4 frag (v2f i) : SV_Target
{
return _Color;
}
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/UnlitVertexColor.shader
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Shader "ProBuilder/UnlitVertexColor"
return o;
}

half4 frag (v2f i) : COLOR
half4 frag (v2f i) : SV_Target
{
return i.color;
}
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/VertexPicker.shader
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ CGPROGRAM
return o;
}

float4 frag (v2f i) : COLOR
float4 frag (v2f i) : SV_Target
{
return i.color;
}
Expand Down
2 changes: 1 addition & 1 deletion Content/Shader/VertexShader.shader
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Shader "Hidden/ProBuilder/VertexShader"
return o;
}

half4 frag (v2f i) : COLOR
half4 frag (v2f i) : SV_Target
{
return _Color;
}
Expand Down
5 changes: 2 additions & 3 deletions Tests/Editor/Import/MeshImporterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ public static void ImportQuads_MatchesWindingOrder()
{
var srcPath = TestUtility.temporarySavedAssetsDirectory + "maya-cube-quads.fbx";

// do this song and dance because AssetDatabase.LoadAssetAtPath doesn't seem to work with models in the
// Package directories
File.Copy(TestUtility.templatesDirectory + "MeshImporter/maya-cube-quads.fbx", srcPath);
// overwrite: UTR retries in-fixture, and a leftover copy would fail every later attempt.
File.Copy(TestUtility.templatesDirectory + "MeshImporter/maya-cube-quads.fbx", srcPath, true);
AssetDatabase.Refresh();
var source = AssetDatabase.LoadMainAssetAtPath(srcPath);
var meshImporter = (ModelImporter)AssetImporter.GetAtPath(srcPath);
Expand Down
38 changes: 20 additions & 18 deletions Tests/Framework/TestUtility.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using NUnit.Framework;
using UnityEditor;
using UnityEditor.SceneManagement;
Expand Down Expand Up @@ -333,45 +333,44 @@ public static bool MeshesAreEqual(Mesh expected, Mesh result)
return true;
}

public static string GetTemplatePath<T>(string assetName, int methodOffset = 0)
public static string GetTemplatePath<T>(string assetName,
[CallerFilePath] string callingFilePath = null,
[CallerMemberName] string callingMemberName = null)
{
StackTrace trace = new StackTrace(1 + methodOffset, true);
StackFrame calling = trace.GetFrame(0);

string filePath = calling.GetFileName();

if (string.IsNullOrEmpty(filePath))
if (string.IsNullOrEmpty(callingFilePath))
{
UnityEngine.Debug.LogError(
"Cannot generate mesh templates directory path from calling method. Please use the explicit SaveMeshTemplate overload.");
return null;
}

// Get the calling file path relative to the `Tests/` directory
string fullFilePath = Path.GetFullPath(filePath).Replace("\\", "/");
string fullFilePath = Path.GetFullPath(callingFilePath).Replace("\\", "/");
string fullTestRootPath = Path.GetFullPath(testsRootDirectory).Replace("\\", "/");
string relativeTemplatePath = fullFilePath.Replace(fullTestRootPath, "");
string relativeTemplateDir = Path.GetDirectoryName(relativeTemplatePath).Replace("\\", "/").TrimStart('/');

string methodName = calling.GetMethod().Name;

return string.Format("{0}/{1}/{2}/{3}/{4}.asset",
typeof(T).ToString(),
relativeTemplateDir,
Path.GetFileNameWithoutExtension(filePath),
methodName,
Path.GetFileNameWithoutExtension(callingFilePath),
callingMemberName,
assetName);
}

/// <summary>
/// Get a mesh saved from the same path with name. Use SaveAssetTemplate to automatically generate this path.
/// </summary>
/// <param name="name"></param>
/// <param name="callingFilePath"></param>
/// <param name="callingMemberName"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static T GetAssetTemplate<T>(string name) where T : UObject
public static T GetAssetTemplate<T>(string name,
[CallerFilePath] string callingFilePath = null,
[CallerMemberName] string callingMemberName = null) where T : UObject
{
string assetPath = templatesDirectory + GetTemplatePath<T>(name, 1);
string assetPath = templatesDirectory + GetTemplatePath<T>(name, callingFilePath, callingMemberName);
T asset = AssetDatabase.LoadAssetAtPath<T>(assetPath);
Assert.IsFalse(asset == null, "Failed loading asset template " + name + " at path " + assetPath);
return asset;
Expand All @@ -393,11 +392,14 @@ public static T GetAssetTemplateWithPath<T>(string pathRelativeToTemplatesDirect
/// </remarks>
/// <param name="asset"></param>
/// <param name="name"></param>
/// <param name="methodOffset"></param>
/// <param name="callingFilePath"></param>
/// <param name="callingMemberName"></param>
/// <typeparam name="T"></typeparam>
public static void SaveAssetTemplate<T>(T asset, string name = null, int methodOffset = 0) where T : UObject
public static void SaveAssetTemplate<T>(T asset, string name = null,
[CallerFilePath] string callingFilePath = null,
[CallerMemberName] string callingMemberName = null) where T : UObject
{
string templatePath = GetTemplatePath<T>(string.IsNullOrEmpty(name) ? asset.name : name, methodOffset + 1);
string templatePath = GetTemplatePath<T>(string.IsNullOrEmpty(name) ? asset.name : name, callingFilePath, callingMemberName);
SaveAssetTemplateAtPath(asset, templatePath);
}

Expand Down
4 changes: 4 additions & 0 deletions Tests/Runtime/MeshOps/BridgeEdgesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
using UnityEngine.ProBuilder.Shapes;
using UnityEngine.ProBuilder.Tests;
using UnityEngine.ProBuilder.Tests.Framework;
using UnityEngine.TestTools;

#if ENABLE_CORECLR
[Explicit("ProBuilder test mesh templates resolve their asset path from StackTrace calling-method info, which fails on CoreCLR, see https://jira.unity3d.com/browse/UUM-148933")]
#endif
static class BridgeEdgesTests
{
[Test]
Expand Down
4 changes: 4 additions & 0 deletions Tests/Runtime/MeshOps/CollapseVerticesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
using UnityEngine.ProBuilder.Shapes;
using UnityEngine.ProBuilder.Tests;
using UnityEngine.ProBuilder.Tests.Framework;
using UnityEngine.TestTools;

#if ENABLE_CORECLR
[Explicit("ProBuilder test mesh templates resolve their asset path from StackTrace calling-method info, which fails on CoreCLR, see https://jira.unity3d.com/browse/UUM-148933")]
#endif
static class CollapseVerticesTests
{
[Test]
Expand Down
4 changes: 4 additions & 0 deletions Tests/Runtime/MeshOps/DeleteElementsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using UnityEngine.ProBuilder.Shapes;
using UnityEngine.ProBuilder.Tests;
using UnityEngine.ProBuilder.Tests.Framework;
using UnityEngine.TestTools;

static class DeleteElementsTests
{
Expand Down Expand Up @@ -89,6 +90,9 @@ public static void Cleanup()
}

[Test]
#if ENABLE_CORECLR
[Explicit("ProBuilder test mesh templates resolve their asset path from StackTrace calling-method info, which fails on CoreCLR, see https://jira.unity3d.com/browse/UUM-148933")]
#endif
public static void DeleteFirstFace_CreatesValidMesh([ValueSource("shapeTypes")] Type shape)
{
var mesh = ShapeFactory.Instantiate(shape);
Expand Down
9 changes: 9 additions & 0 deletions Tests/Runtime/MeshOps/ExtrudeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public static void Extrude_MultipleEdges_CreatesValidGeometry()
}

[Test]
#if ENABLE_CORECLR
[Explicit("ProBuilder test mesh templates resolve their asset path from StackTrace calling-method info, which fails on CoreCLR, see https://jira.unity3d.com/browse/UUM-148933")]
#endif
public static void ExtrudeAllFaces_FaceNormal([ValueSource("m_AvailableShapeTypes")] Type shape)
{
var mesh = ShapeFactory.Instantiate(shape);
Expand All @@ -107,6 +110,9 @@ public static void ExtrudeAllFaces_FaceNormal([ValueSource("m_AvailableShapeType
}

[Test]
#if ENABLE_CORECLR
[Explicit("ProBuilder test mesh templates resolve their asset path from StackTrace calling-method info, which fails on CoreCLR, see https://jira.unity3d.com/browse/UUM-148933")]
#endif
public static void ExtrudeAllFaces_IndividualFaces([ValueSource("m_AvailableShapeTypes")] Type shape)
{
var mesh = ShapeFactory.Instantiate(shape);
Expand Down Expand Up @@ -135,6 +141,9 @@ public static void ExtrudeAllFaces_IndividualFaces([ValueSource("m_AvailableShap
}

[Test]
#if ENABLE_CORECLR
[Explicit("ProBuilder test mesh templates resolve their asset path from StackTrace calling-method info, which fails on CoreCLR, see https://jira.unity3d.com/browse/UUM-148933")]
#endif
public static void ExtrudeAllFaces_VertexNormal([ValueSource("m_AvailableShapeTypes")] Type shape)
{
var mesh = ShapeFactory.Instantiate(shape);
Expand Down
4 changes: 4 additions & 0 deletions Tests/Runtime/MeshOps/TextureUnwrapTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
using UnityEngine.ProBuilder.Shapes;
using UnityEngine.ProBuilder.Tests;
using UnityEngine.ProBuilder.Tests.Framework;
using UnityEngine.TestTools;

#if ENABLE_CORECLR
[Explicit("ProBuilder test mesh templates resolve their asset path from StackTrace calling-method info, which fails on CoreCLR, see https://jira.unity3d.com/browse/UUM-148933")]
#endif
static class TextureUnwrapTests
{
static readonly Type[] offsetRotationShapes = new Type[]
Expand Down
4 changes: 4 additions & 0 deletions Tests/Runtime/MeshOps/VertexColorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
using UnityEngine.ProBuilder.Shapes;
using UnityEngine.ProBuilder.Tests;
using UnityEngine.ProBuilder.Tests.Framework;
using UnityEngine.TestTools;

#if ENABLE_CORECLR
[Explicit("ProBuilder test mesh templates resolve their asset path from StackTrace calling-method info, which fails on CoreCLR, see https://jira.unity3d.com/browse/UUM-148933")]
#endif
static class VertexColorTests
{
[Test]
Expand Down
4 changes: 4 additions & 0 deletions Tests/Runtime/Shape/ShapeGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System;
using UnityEngine.ProBuilder.Shapes;
using UnityEngine.ProBuilder.Tests.Framework;
using UnityEngine.TestTools;

class ShapeGeneratorTests
{
Expand All @@ -25,6 +26,9 @@ public static List<Type> shapeTypes {
}

[Test]
#if ENABLE_CORECLR
[Explicit("ProBuilder test mesh templates resolve their asset path from StackTrace calling-method info, which fails on CoreCLR, see https://jira.unity3d.com/browse/UUM-148933")]
#endif
public void ShapeGenerator_MatchesTemplate([ValueSource("shapeTypes")] Type type)
{
ProBuilderMesh pb = ShapeFactory.Instantiate(type);
Expand Down
10 changes: 10 additions & 0 deletions Tests/Runtime/Type/VertexTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System;
using UnityEngine.ProBuilder;
using UnityEngine.TestTools;

static class TestHashUtility
{
Expand Down Expand Up @@ -56,6 +57,9 @@ static Vertex RandVertex()
}

[Test]
#if ENABLE_CORECLR
[Explicit("ProBuilder IntVec3/VectorHash float hashing produces different values on CoreCLR, see https://jira.unity3d.com/browse/UUM-148935")]
#endif
public static void TestHashCollisions_IVEC3()
{
#if UNITY_EDITOR_OSX
Expand All @@ -68,6 +72,9 @@ public static void TestHashCollisions_IVEC3()
}

[Test]
#if ENABLE_CORECLR
[Explicit("ProBuilder IntVec3/VectorHash float hashing produces different values on CoreCLR, see https://jira.unity3d.com/browse/UUM-148935")]
#endif
public static void TestVectorHashOverflow()
{
#if UNITY_EDITOR_OSX
Expand All @@ -88,6 +95,9 @@ public static void TestVectorHashOverflow()
}

[Test]
#if ENABLE_CORECLR
[Explicit("ProBuilder IntVec3/VectorHash float hashing produces different values on CoreCLR, see https://jira.unity3d.com/browse/UUM-148935")]
#endif
public static void TestComparison_IVEC3()
{
#if UNITY_EDITOR_OSX
Expand Down