2015-03-31 39 views
0

我特别从可从Unity资源商店下载的IntegrationTest类中获取此错误。Path.GetFileNameWithoutExtension在Unity 5中抛出错误

说的投掷错误的具体线路是在这里:

var fileName = Path.GetFileNameWithoutExtension(sceneName); 

但你可以在上下文中看到它在这里。

[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] 
public class DynamicTestAttribute : Attribute 
{ 
    private readonly string m_SceneName; 

    public DynamicTestAttribute(string sceneName) 
    { 
     if (sceneName.EndsWith(".unity")) 
      sceneName = sceneName.Substring(0, sceneName.Length - ".unity".Length); 
     m_SceneName = sceneName; 
    } 

    public bool IncludeOnScene(string sceneName) 
    { 
     var fileName = Path.GetFileNameWithoutExtension(sceneName); 
     return fileName == m_SceneName; 
    } 
} 

的统一编译器说:

Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/IntegrationTest.cs(154,33): error CS0117: `Path' does not contain a definition for `GetFileNameWithoutExtension' 

按照统一的文档,这是正确使用。也许有一个我错过的Unity 5的新文档链接。

回答

1

请注意,您可以使用“使用Path = System.IO.Path;”行来解决错误。在源文件的顶部。 (我知道在这种情况下,这不是你的代码,但是如果你想在本地修复它,或者任何人都有问题。)

感谢@yoyo提供的答案!

0

好的,所以问题是我刚刚从Asset Store中导入了iTween示例,它有一个名为Path的类,因此两个类定义 - Unity的默认定义和iTweens示例中的定义是冲突的,编译器已经决定iTween是'''',它不包含上面提到的方法。

也许我应该发送Pixel Placement球员关于它的一个笔记。

+0

好主意,这是淘气的iTween。请注意,您可以使用“使用Path = System.IO.Path”行来解决错误。在源文件的顶部。 (在这种情况下,我意识到这不是你的代码,但是如果你想在本地修复它,或者其他人都有问题)。 – yoyo 2015-03-31 04:51:25

+0

哇!真棒洞察力的技巧谢谢你! – 2015-04-01 08:35:40

+0

@ yoyo你已经完全解决了我的问题与这个答案。 – 2015-04-03 07:37:28