unity3d错误这个错误怎么回事

你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
本帖最后由 Jeason-L 于
20:25 编辑
这代码是公开课第六讲的jsp代码,我改用C#写,结果报错了,超级无奈,不懂哪里出错了,求大神打救啊!
using UnityE
using System.C
public class showTex : MonoBehaviour {
Texture2D oneT
Object[] allT
void OnGUI()
if(GUI.Button(Rect(0,20,100,60),"loadOneTexture"))
if(oneTexture==null)
oneTexture=(Texture2D)Resources.Load("oneTexture/Grass");
if(GUI.Button(Rect(0,140,10,60),"loadallTexture"))
if(allTexture==null)
allTexture=Resources.LoadAll("allTexture");
if(oneTexture!=null)
GUI.DrawTexture(Rect(110,20,120,120),oneTexture,ScaleMode.StretchToFill,true,0);
if(allTexture!=null)
for(var i=0;i<allTexture.Li++)
GUI.DrawTexture(Rect(110*i+120,140,120,120),allTexture,ScaleMode.StretchToFill,true,0);
这代码是公开课第六讲jsp代码,我改用C#写,结果报错了,超级无奈,求大神打救啊!
报错内容:
Assets/showTex.cs(11,31): error CS0119: Expression denotes a type', where avariable', value' ormethod group' was expected
Assets/showTex.cs(11,24): error CS1502: The best overloaded method match for `UnityEngine.GUI.Button(UnityEngine.Rect, string)' has some invalid arguments
Assets/showTex.cs(11,24): error CS1503: Argument #1' cannot convertobject' expression to type `UnityEngine.Rect'
Assets/showTex.cs(20,31): error CS0119: Expression denotes a type', where avariable', value' ormethod group' was expected
Assets/showTex.cs(20,24): error CS1502: The best overloaded method match for `UnityEngine.GUI.Button(UnityEngine.Rect, string)' has some invalid arguments
Assets/showTex.cs(20,24): error CS1503: Argument #1' cannot convertobject' expression to type `UnityEngine.Rect'
Assets/showTex.cs(24,55): error CS0030: Cannot convert type UnityEngine.Object[]' toUnityEngine.Texture2D'
Assets/showTex.cs(30,41): error CS0119: Expression denotes a type', where avariable', value' ormethod group' was expected
Assets/showTex.cs(30,29): error CS1502: The best overloaded method match for `UnityEngine.GUI.DrawTexture(UnityEngine.Rect, UnityEngine.Texture, UnityEngine.ScaleMode, bool, float)' has some invalid arguments
Assets/showTex.cs(30,29): error CS1503: Argument #1' cannot convertobject' expression to type `UnityEngine.Rect'
Assets/showTex.cs(37,49): error CS0119: Expression denotes a type', where avariable', value' ormethod group' was expected
Assets/showTex.cs(37,37): error CS1502: The best overloaded method match for `UnityEngine.GUI.DrawTexture(UnityEngine.Rect, UnityEngine.Texture, UnityEngine.ScaleMode, bool, float)' has some invalid arguments
Assets/showTex.cs(37,37): error CS1503: Argument #1' cannot convertobject' expression to type `UnityEngine.Rect'
本帖最后由 lanchong101 于
19:56 编辑
Rect(0,20,100,60); 如果英语不好建议你装一个翻译软件 有道或者金山!
allTexture=(Texture2D)Resources.LoadAll("allTexture");
LoadAll返回的是一个 Obj数组
Rect(0,20,100,60); 如果英语不好建议你装一个翻译软件 有道或者金山!
allTexture=(Texture2 ...谢谢大神
allTexture=(Texture2D)Resources.LoadAll("allTexture");
这一行是我从网上查修改方法.加上了(Texture2D) 忘记删除了
在rece前面加上new之后 现在剩下37行的错误.错在哪里呢?
GUI.DrawTexture(Rect(110,20,120,120),oneTexture,ScaleMode.StretchToFill,true,0);
GUI.DrawTexture(new Rect(110 * i + 120, 140, 120, 120), allTexture as Texture2D , ScaleMode.StretchToFill, true, 0);
必须要指定返回值 吗?
要回复问题请先或
浏览: 4465
关注: 0 人解决&unity&3d&web&player&的一个错误&error&launching&unit
系统环境为 Windows Xp sp3 + IE6
安装了 unity web player 之后上打开 unity的页面,会有 Error launching unity player
IE6,Chrome均有这样的提示:
为了解决它,找了N N N N N久,不过问题总算是找到了,付修复工具。
修复工具下载:
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。2017年3月 .NET技术大版内专家分月排行榜第三2017年2月 .NET技术大版内专家分月排行榜第三2016年9月 .NET技术大版内专家分月排行榜第三2016年8月 .NET技术大版内专家分月排行榜第三2016年7月 .NET技术大版内专家分月排行榜第三2016年3月 .NET技术大版内专家分月排行榜第三2016年1月 .NET技术大版内专家分月排行榜第三2015年12月 .NET技术大版内专家分月排行榜第三2015年11月 .NET技术大版内专家分月排行榜第三
匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。帮我分析一下错误原因,以及如何处理
来源:csdn
【用户代码未处理 posite.Presentation.Regions.Behaviors.RegionCreationException
Message=An exception occurred while creating a region with name 'MenuRegion'. The exception was: Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Silverlight.Modules.Main.Views.IMenuViewModel", name = "(none)".
Exception occurred while: Calling constructor Silverlight.Modules.Main.Views.MenuViewModel(Silverlight.Modules.Main.Views.IMenuView view, Microsoft.Practices.Unity.IUnityContainer container, posite.Events.IEventAggregator eventAggregator).
Exception is: ResolutionFailedException - Resolution of the dependency failed, type = "Silverlight.Modules.Main.Controllers.IMainController", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, Silverlight.Modules.Main.Controllers.IMainController, is an interface and cannot be constructed. Are you missing a type mapping?
-----------------------------------------------
At the time of the exception, the container was:
Resolving Silverlight.Modules.Main.Controllers.IMainController,(none)
-----------------------------------------------
At the time of the exception, the container was:
Resolving Silverlight.Modules.Main.Views.MenuViewModel,(none) (mapped from Silverlight.Modules.Main.Views.IMenuViewModel, (none))
Calling constructor Silverlight.Modules.Main.Views.MenuViewModel(Silverlight.Modules.Main.Views.IMenuView view, Microsoft.Practices.Unity.IUnityContainer container, posite.Events.IEventAggregator eventAggregator)
---> Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Silverlight.Modules.Main.Controllers.IMainController", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, Silverlight.Modules.Main.Controllers.IMainController, is an interface and cannot be constructed. Are you missing a type mapping?
-----------------------------------------------
At the time of the exception, the container was:
Resolving Silverlight.Modules.Main.Controllers.IMainController,(none)
---> System.InvalidOperationException: The current type, Silverlight.Modules.Main.Controllers.IMainController, is an interface and cannot be constructed. Are you missing a type mapping?
位于 Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForAttemptingToConstructInterface(IBuilderContext context)
位于 BuildUp_Silverlight.Modules.Main.Controllers.IMainController(IBuilderContext )
位于 Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
位于 Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
位于 Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
位于 Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
--- 内部异常堆栈跟踪的结尾 ---
位于 Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
位于 Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name, IEnumerable`1 resolverOverrides)
位于 Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
位于 Microsoft.Practices.Unity.UnityContainerExtensions.Resolve[T](IUnityContainer container, ResolverOverride[] overrides)
位于 Silverlight.Modules.Main.Views.MenuViewModel.InitializeButtons()
位于 Silverlight.Modules.Main.Views.MenuViewModel..ctor(IMenuView view, IUnityContainer container, IEventAggregator eventAggregator)
位于 BuildUp_Silverlight.Modules.Main.Views.MenuViewModel(IBuilderContext )
位于 Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
位于 Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
位于 Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
位于 Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
--- 内部异常堆栈跟踪的结尾 ---
位于 Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
位于 Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name, IEnumerable`1 resolverOverrides)
位于 Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
位于 Microsoft.Practices.Unity.UnityContainerExtensions.Resolve[T](IUnityContainer container, ResolverOverride[] overrides)
位于 Silverlight.Modules.Main.MainModule.b__1()
位于 posite.Presentation.Regions.RegionViewRegistry.GetContents(String regionName)
位于 posite.Presentation.Regions.Behaviors.AutoPopulateRegionBehavior.CreateViewsToAutoPopulate()
位于 posite.Presentation.Regions.Behaviors.AutoPopulateRegionBehavior.StartPopulatingContent()
位于 posite.Presentation.Regions.Behaviors.AutoPopulateRegionBehavior.OnAttach()
位于 posite.Presentation.Regions.RegionBehavior.Attach()
位于 posite.Presentation.Regions.RegionBehaviorCollection.Add(String key, IRegionBehavior regionBehavior)
位于 posite.Presentation.Regions.RegionAdapterBase`1.AttachDefaultBehaviors(IRegion region, T regionTarget)
位于 posite.Presentation.Regions.RegionAdapterBase`1.Initialize(T regionTarget, String regionName)
位于 posite.Presentation.Regions.RegionAdapterBase`1.posite.Regions.IRegionAdapter.Initialize(Object regionTarget, String regionName)
位于 posite.Presentation.Regions.Behaviors.DelayedRegionCreationBehavior.CreateRegion(DependencyObject targetElement, String regionName).
StackTrace:
位于 posite.Presentation.Regions.Behaviors.DelayedRegionCreationBehavior.CreateRegion(DependencyObject targetElement, String regionName)
位于 posite.Presentation.Regions.Behaviors.DelayedRegionCreationBehavior.TryCreateRegion()
位于 posite.Presentation.Regions.Behaviors.DelayedRegionCreationBehavior.ElementLoaded(Object sender, RoutedEventArgs e)
位于 MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
位于 MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
InnerException: Microsoft.Practices.Unity.ResolutionFailedException
Message=Resolution of the dependency failed, type = "Silverlight.Modules.Main.Views.IMenuViewModel", name = "(none)".
Exception occurred while: Calling constructor Silverlight.Modules.Main.Views.MenuViewModel(Silverlight.Modules.Main.Views.IMenuView view, Microsoft.Practices.Unity.IUnityContainer container, posite.Events.IEventAggregator eventAggregator).
Exception is: ResolutionFailedException - Resolution of the dependency failed, type = "Silverlight.Modules.Main.Controllers.IMainController", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, Silverlight.Modules.Main.Controllers.IMainController, is an interface and cannot be constructed. Are you missing a type mapping?】
你使用了PRISM么?其中创建'MenuRegion'实例失败,应该这里引用为null了,检查一下错误行是否被提前实例成功。
Calling constructor 这个异常吧,楼主看这个函数里的就行了应该是构造函数
yanggenxiang:
是的,我用了Prism,我再看一下程序。
frank6027:
Calling constructor 这个异常吧,楼主看这个函数里的就行了应该是构造函数
yanggenxiang:
谢谢大家。
免责声明:本站部分内容、图片、文字、视频等来自于互联网,仅供大家学习与交流。相关内容如涉嫌侵犯您的知识产权或其他合法权益,请向本站发送有效通知,我们会及时处理。反馈邮箱&&&&。
学生服务号
在线咨询,奖学金返现,名师点评,等你来互动Unity3D引擎崩溃、异常、警告、BUG与提示总结及解决方法 | Unity3D教程手册
当前位置 :
>> Unity3D引擎崩溃、异常、警告、BUG与提示总结及解决方法
Unity3D引擎崩溃、异常、警告、BUG与提示总结及解决方法
1.Unity3D经常莫名奇妙崩溃。
一般是由于空异常造成的,多多检查自己的引用是否空指针。
2.编码切换警告提示。
警告提示:Some are Mac OS X (UNIX) and some are Windows.
This might lead to incorrect line numbers in stacktraces andcompiler errors. Many text editors can fix this using Convert LineEndings menu commands.
编码格式问题,VS的话直接高级保存方案里面修改,一般我选的是UNICODE(UTF8代签名)MACINTOSH(CR),WINDOW下的可以选WINDOWS的格式,两边都要用的话,推荐选CR。
3.中文界面解决问题。
monodevelop中文显示解决方法:/bbs/read.php?tid-78563.html
中文Mac系统下MonoDevelop乱码解决:http://blog.csdn.net/ssihc0/article/details/6796118
4.安装空项目报错
不知道怎么地,在IOS试过一次空项目也在错误提示。大概是说什么“找不到需要的方法”。
重装一下就好了,估计是UNITY文件损坏或者安装不完全出错了。
错误提示:MissingMethodException: Cannot find the requestedmethod.
估计是破解Unity3D造成的,该破解文件可能是不支持WIN7下的。
解决方法:换正版或换个破解文件。
5.平台编译错误或库引用缺失
错误提示:error CS1061: Type `System.IO.FileInfo' does not containa definition for `Delete' and no extension method `Delete' of type`System.IO.FileInfo' could be found (are you missing a usingdirective or an assembly reference?)
出了这个错误一般有两个原因了。
1.没有引用相关的库。
2.选错编译平台。(BuildSetting里面的Platform)
错误提示:Could not startcompilationWin32Exception:ApplicationName=“XXXX\mono.exe”,……
解决方式:重装UNITY3D。
6.内存资源加载错误问题
错误提示:Trying to reload asset from disk that is not stored ondisk
个人是在加载多个ASSETBUNDLE时,用了释放镜像之后,发生了下面的BUG。
这个警告它并没有对游戏流程有任何影响,不过一直跳出来很烦人。我们项目中是因为用Dictionary删除的时候没有删除完整导致的。
解决方案参考:.cn/s/blog_5b6cbipi.html
个人认为比较大可能是下面的原因:
还没释放完镜像再次加载就出BUG了。将所有ASSETBUNDLE加载完后再同一释放,这样就没问题了。
Unity will only allow you to have a single instance of aparticular AssetBundle loaded at one time in your application. Whatthis means is that you can't retrieve an AssetBundle from a WWWobject if the same one has been loaded previously and has not beenunloaded. In practical terms it means that when you try to access apreviously loaded AssetBundle like this:
(BY:/Documentation/Manual/keepingtrackofloadedassetbundles.html)
国外论坛的讨论:
/threads/49298-Trying-to-reload-asset-from-disk-that-is-not-stored-on-disk
貌似老外也没完全确切搞定这个。
错误提示:Deletingpersistent object without writing it first
不论如何你都不应该直接修改一个从assetbundle加载进来的最初数据,一般都要先实例化出来再对其修改。但是引用的东西(例如mesh),这些也不能修改它。若要修改的话,则先复制一份出来。
复制一份模型出来重新复制,以免直接修改被引用的镜像模型。如下:
&&&1 Mesh temp = Mesh.Instantiate&#40;smr.sharedMesh&#41; as Mesh;2&3  myMesh.sharedMesh = temp;
7.时间错误、NaN错误
错误提示:transform.position assign attempt for 'XXX' is notvalid。Input rotation is {NaN, NaN, NaN, NaN}.
一般是由于游戏暂停将timescale设为0引起的,需要寻找相应用了Time.deltTime等参数的函数修改。否则会导致计算出错报空异常。
详细解决看另一篇文章:关于NaN(Not a Number)的问题.cn/s/blog_5b6cbe.html
8.动画错误
这个错误是4.0新引进动画系统才出现的。
错误提示:Mecanim: BindSkeleton: Cannot findtransform“objectname”
解决方式:
1.找到该对应transform“objectname”的模型,直接在检索面板搜索所有相应名字,能容易找到。
2.将模型的面板的Rig部分的动画AnimationType改为none
9.坐标系向量计算的错误提示
错误提示:Look rotation viewing vector is zero
解决方式:一般是由于摄像机的旋转角度造成的。也可能是向量的计算多余而系统提示。我们项目中是强制摄像机90度的时候出现,改成89.9度就没问题了。
具体还有的参考Unity3D官方论坛:
/questions/397425/look-rotation-viewing-vector-is-zero-error.html
若没找到解决方法再搜索下。
10.关于AssetServer
错误:明明上传了所有修改,但是别人的机子却没有下载带最新代码。
原因:Merge完代码之后,操作了ignore serverchange,UNITY默认是以你本机子的为准,若此代码没有再次修改,则AssetServer不认为这个东西被修改过,没有上传那代码。
解决方式:打个空格重新保存一下该代码。
11.关于数据格式的错误
错误提示:IllegalJSON sequence
解决方式:/threads/143168-JsonFX-WTF-Illegal-JSON-sequence
12.导出WINDOS平台下的项目运行不成功
错误提示:没有找到相应assetbundle的路径
解决方式:因为用了assetbundle加载,而游戏在有中文路径下,assetbundle的路径不能有中文。换个无中文的目录即可。从根源上能解决的方案现在暂时没有。
13.导入资源出错
错误提示:Error while importing package :Couldn't decompresspackage
解决方式:导入资源出错,大部分都是中文路径惹的祸。将资源换到无中文路径试试。如C/D盘根目录。
【上一篇】
【下一篇】
您可能还会对这些文章感兴趣!

我要回帖

更多关于 unity 错误日志 的文章

 

随机推荐