unity3d 之-error记

1、unity3d安装一系列不成功

//解决:未断网

 

2Error while importing package:coudn't decompess package.

//解决:NGUI-package路径包含中文

 

3、You can't rtace widgets on a layer different than the uipanel that manages then. If you want to move widgets to adifferents layer.parent then to a new panel instead.

 

4、unassigneReferenceException:The wariable newobject of"create" has not been assigned.You probably need to assign the newobject variable of the create script in the inspector.   create 是我创建的挂在相机下的C#脚本,newobject Transform对象--public Transform newobject ; (暴露变量,加上public,在试图中可见这个变量且易修改);   //解决:为newobject 赋值,可直接拖曳一个Transfrom对象(如:Cube)挂在这个暴露变量身上

 

5NullReferenceExeption:UnityEngine Object,Internal-InstantiateSingle(unityEngine.object...) 

  //解决:将参数unityEngine.obje改为public

 

6、ArgumentException:The prefab you want to instantiate is null . unityEngine.object.CheckNullArgument 

//解决:将变量改为暴露变量+public

 

7、error CS1502:The best overloaded methoalde match for'unityEngine Debug.Log(、、)has some invalid arguments.   error CS1503:Arguments '# 2' cannot 'convert' float'expressimt tyoe'unityengine.Object'.// 解决:在Log("speed ",speed)中,用+-------------Log("speed"+speed).

 

8error CS0120An object reference is requrired to access non-static member 

 //解决:其实就是静态函数中用到了未实例化的非静态字段的问题 如:public int m_itest; public static addTest(){ m_itest = 1;} public int m_itest;改成static int m_itest;即可

 

9error CS0165: use of unassigned local variable   

//  解决:定义了一个变量 将其写在函数外就好了

 

10IEnumerator PlayAni(float timer); 直接调用PlayAni0.5f,不出错但也怎么都不进函数执行动画内容,

// 解决:必须要StartCoroutnie(PlayAni(0.5f)); 开始协同程序(MonoBehaviour

 

11UI编辑场景里看不到UI,Game显示正常 

// 解决:设置Layer -- Everything

 

12IndexOutOfRangeException: Array index is out of range.  

UIManager.PollMouseAndTouchpad () (at Assets/Plugins/EZ/GUI/Management/UIManager.cs:1208)  

UIManager.Update () (at Assets/Plugins/EZ/GUI/Management/UIManager.cs:870)  

// 解决:方案一:File-- Build Settings--Android--Switch Platform  

二:修改UIManager--Pointer Type 对应的值  

 

 

13、Material doesn't have a color property '_Color'

UnityEngine.Material:.ctor(Material)
Cache:Obtain() (at Assets/Daikon Forge/DFGUI/Scripts/dfGUIManager.cs:2808)
MaterialCache:Lookup(Material) (at Assets/Daikon Forge/DFGUI/Scripts/dfGUIManager.cs:2715)
dfGUIManager:gatherMaterials() (at Assets/Daikon Forge/DFGUI/Scripts/dfGUIManager.cs:1997)
dfGUIManager:Render() (at Assets/Daikon Forge/DFGUI/Scripts/dfGUIManager.cs:1611)
dfGUIManager:LateUpdate() (at Assets/Daikon Forge/DFGUI/Scripts/dfGUIManager.cs:987)

// 解决:打包资源对应平台是手机平台,然后在unity编辑器上运行,有时会报此错误,有时游戏会直接显示不明,
运行在Hierarchy中查看其物体Shader是否是以贴图方式绘制,如果是alpha就不对了
BuildPipeline.BuildAssetBundle(Selection.activeObject,null,path,BuildAssetBundleOptions.CollectDependencies| BuildAssetBundleOptions.CompleteAssets,BuildTarget.StandaloneWindows64)
                                    
14、error CS0621: `LoadAssetbundleManager.LoadGameMenuMode()': virtual or abstract members cannot be private 

//解决:将函数前加public即可


15:、error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement 
void Start () 


{
//解决://开启协同加载  这句话 去掉即好 不解  其实就是加了一句注释


StartCoroutine(LoadALLGameObject());
}



16、error CS1519: Unexpected symbol `{' in class, struct, or interface member declaration 不解
public bool bIsUse_OneSlef_Camera = false;//此默认为UICamera 新加的实例将默认挂在UIRoot


void Start () 


{
}
函数与bIsUse_OneSlef_Camera之间加个回车空格就好了 这是怎么了?



17、error CS0200: Property or indexer `UnityEngine.GameObject.camera' cannot be assigned to (it is read only)

18、error CS0246: The type or namespace name `Dictionary' could not be found. Are you missing a using directive or an assembly reference?
public Dictionary <string,GameObject> m_InstanceObj = new Dictionary(); 

//解决:改为

public Dictionary<string, GameObject> m_InstanceObj= new Dictionary<string,GameObject >();

 

19、ArrayList m_arrayListTemp; 

m_arrayListTemp.Add(GameObject对象名)

m_arrayListTemp.Clear();

m_arrayListTemp.Count;

 

20、Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.

D:\Tools\jdk\bin\java.exe -Xmx1024M -Dcom.android.sdkmanager.toolsdir="D:/Tools/androidTools/android_sdk_windows/android_sdk_windows\tools" -Dfile.encoding=UTF8 -jar "D:/Program Files (x86)/Unity/Editor/Data/BuildTargetTools/AndroidPlayer\sdktools.jar" -

//解决:在你的Android工程中的AndroidManifest.xmlstrings.xml等.xml文件中前加 <?xml version="1.0" encoding="utf-8"?> 然后到处.jar再unity工程加入此.jar 打包.apk就没此问题了

 

21、Exception: JNI: Init'd AndroidJavaClass with null ptr!

UnityEngine.AndroidJavaClass..ctor (IntPtr jclass) (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/AndroidJavaImpl.cs:539)

  // 解决:需真机测试

 

22:No Compatible targets were foound.Do you wish to add a new Android Virtual Device

   // 解决:没有Device

 

22、Level 'mainmenu' (-1) couldn't be loaded because it has not been added to the build settings.  

To add a level to the build settings use the menu File->Build Settings...// 解决:这句是解决方案  

UnityEngine.Application:LoadLevelAsync(String)  

<LoadDetailedAssetbundle>c__Iterator17:MoveNext() (at Assets/Scripts/mode/loading/LoadAssetbundleManager.cs:120)  

  

23、//碰撞器  

UnityException: Tag: Player2 is not defined!  

OnTriggerEnter (other : Collider)  

{  

if(other.gameObject.CompareTag ("Player2")) 

//解决:改成 if (other.gameObject.tag == "Player2") 或者 if(other.name == "Player2")  

}  

  

  

24、

Assets/Scripts/Player/WeaponController.js(60,25): BCE0018: The name 'SkeletonAnimation' does not denote a valid type ('not found'). Did you mean 'UnityEngine.SkeletonBone'?  

  // 解决:将 SpineTool的所有.cs 放到项目 Assests-Plugins文件夹下  

  

25、BCE0023: No appropriate version of 'Spine.AnimationState.AddAnimation' for the argument list '(int, String, boolean)' was found.  

   我是这么写的 skeletonAnimation.state.AddAnimation(0,"idle",true);  

  // 解决:少传了一个参数 skeletonAnimation.state.AddAnimation(0,"idle",true0.5f);  

  

26、有时候 Spine 人物骨骼动画 不播放或者说播放帧数不对:   

    //解决:查找看看是不是同时间还在播放这个人物的另一个动作  

  

27、An asset is marked as dont save, but is included in the build:  

Asset: 'Assets/Resources/Player/PlayerModels/shamozhiying/data/shamozhiying Atlas.asset'  

UnityEditor.HostView:OnGUI()  

Building - Failed to write file: 5b97ffcec9b15e740aa4b4efd295fe1d  

UnityEditor.HostView:OnGUI()  

Error building Player: Couldn't build player because of unsupported data on target platform.  

 :用的Spine插件 做的 shamozhiying Atlas.asset 

//解决:不能直接复制改名重用 (可怜我做的那么多人物模型,都得重新再做一遍!)  

 

  

28skeletonAnimation.state.问题

Assets/Scripts/Player/WeaponController.js(85,41): BCE0120: 'Spine.AnimationState.data' is inaccessible due to its protection level.--Data  

  

BCE0156: Event 'Complete' can only be triggered from within its declaring type ('Spine.AnimationState').  

  

BCE0032: The event 'Spine.AnimationState.Complete' expects a function reference compatible with 'function(Object, Spine.CompleteArgs): void'.  

  

BCE0043: Unexpected token: state.  

function AniComplete(AnimationState state, int index, int loopCount)  

{  

    playerController.bIsFinishFireAni = true;  

}---->  

function AniComplete(state:AnimationState, index:int, loopCount:int):void  

{  

    playerController.bIsFinishFireAni = true;  

}   

即使就算函数写对了 ,对于用到skeletonAnimation.state.CompleteComlete还是无法用,   

我用JS这么写的skeletonAnimation.state.Complete += AniComplete;它会编译报错说skeletonAnimation.state.Complete不能用作表达式,  

可是C# 或是cocos2dX 这么写就OK!于是我只能放弃使用Spine提供的Complete ,我在Spine.AnimationState加了一个动画完成与否的标示符  

public bool bIsComplete = false;在它的Update()函数中current.OnComplete(this, i, count);一行后加了一个判断  

if (i == (tracks.Count -1))  bIsComplete = true;  

  后我在js中用这个bIsComplete ,确实是实现了动画完成的判断,如果你还在愁,找不到js+spine判断动画完成的方案,就用这个咯  

 

29、Skeleton DataAsset 加载骨骼模型 头部不显示 

//解决:修改Intial Skin 

 

 

30Material doesn't have a color property '_Color'  

UnityEngine.Material:get_color() 

//解决:修改shader 属性  

  

 

31skeletonAnimation.state.SetAnimation(0,"attack", true); 这个好像并没有起实际作用 就真的只是把名字改了而已,

动画没变,反而不动  

改成这样就好了skeletonAnimation.animationName = "attack";  

(之后我每个SetAnimation 动画都改成了skeletonAnimation.animationName = 除了死亡)  

 

32

var direction : Vector3 = Vector3.left * dir;  

var hit : RaycastHit;  

 var layerMask : int = 1 << 9;  

if (Physics.Raycast (thisTransform.position - Vector3( -0.4 * dir,2,0), direction, hit, attackRange,  layerMask)) //射线碰撞  

在子弹预设加入 Rigidody BoxCollider

Npc身上加入  Character Controller

纯碰撞盒碰撞OnTriggerEnter()  (记得BoxCollider里的属性isTrigger勾选,否则不起作用)


33

UnityException: Unable to find suitable JDK installation. Please make sure you have a suitable JDK installation. Android development requires at least JDK 7 (1.7), having JRE only is not enough.  The latest JDK can be obtained from the Oracle website 
http://www.oracle.com/technetwork/java/javase/downloads/index.html

进入http://www.oracle.com/technetwork/java/javase/downloads/index.html链接网站,下载jdk,安装jdk,配置其环境变量,

计算机--系统属性--高级--环境变量--新建JAVA_HOME C:\Program Files (x86)\Java\jdk1.7.0

环境变量--新建 CLASSPATH %JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar

系统变量--新建 Path %JAVA_HOME%\bin

重启Unity。


34、

0 1  2  3  4

5 6  7  8  9

10 11 12 13 14

15 16 17 18 19

 

已知下标获取行列。

MaxCol = 5;

MaxRow = 4;

 

CurRow = index/Max_Col;

CurCol = index%Max_Col;

 

获取行列后,根据输入移动行列。

CurCol--,CurCol++(左右)

CurRow--,CurRow++(上下)

注:边界判断

if(CurCol >= Max_Col)

      CurCol= 0;

if(CurRow >= Max_Row)

      CurRow= 0;

if(CurCol < 0)

      CurCol= Max_Col-1;

if(CurRow < 0)

      CurRow= Max_Row-1;

 

已知行列计算下标;

      CurIndex= CurRow*Max_Col + CurCol;

 

保存一个int下标变量即可做移动和判断。



35、

黄色警告:Tiled GPUperf. warning: RenderTexture color surface (240x150) was not cleared/discarded, doing <run with profiler forinfo>

UnityEngine.Graphics:Blit(Texture,RenderTexture, Material, Int32)

修改unity - Edit - GraphicsEmulation下选择No Emulation


36、

unity导入Fbx模型看不到贴图只能看到线框,---untiy编辑器 右上角Layers点击-show--Everything


37、

Gizmos.DrawLine(newVector3(LevelSetupTemp.LevelX,LevelSetupTemp.LevelY, 0),newVector3(LevelSetupTempTo.LevelX,LevelSetupTempTo.LevelY, 0));

 

UnityException: Gizmo drawing functionscan only be used in OnDrawGizmos and OnDrawGizmosSelected.

 

必须在OnDrawGizmos函数或者OnDrawGizmosSelected中可用


38

发布apk:

Error building Player: UnityException: Bundle Identifier has not been set up correctly
Please set the Bundle Identifier in the Player Settings. The value must follow the convention 'com.YourCompanyName.YourProductName' and can contain alphanumeric characters and underscore.
Each segment must not start with a numeric character or underscore.

Error building Player: UnityException: Bundle Identifier has not been set up correctly
Please set the Bundle Identifier in the Player Settings. The value must follow the convention 'com.YourCompanyName.YourProductName' and can contain alphanumeric characters and underscore.
Each segment must not start with a numeric character or underscore.

(已经有人用过此名字上架过)

Player Settings--Inspector-- Bundle Identifie(r -- package name--包名 --com.myGameName.MyGame)

CommandInvokationFailure: Failed to re-package resources. See the Console for details.
E:/sdk/sdk\platform-tools\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "E:/sdk/sdk\platforms\android-14\android.jar" -F bin/resources.ap_

Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
E:/sdk/sdk\platform-tools\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "E:/sdk/sdk\platforms\android-14\android.jar" -F bin/resources.ap_


 
 

                
  • 0
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Unity3D脚本18:可视化辅助设置类 Gizmos GizmosGizmos用于场景中给出一个可视化的调试或辅助设置。 所有的Gizmos绘制都必须在脚本的OnDrawGizmosOnDrawGizmosSelected函数中完成。 OnDrawGizmos在每一帧都被调用。所有在OnDrawGizmos内部渲染的Gizmos都是可见的。 OnDrawGizmosSelected尽在脚本所附加的物体被选中时调用。 类变量 ◆ static var color : Color // 描述:设置下次绘制的Gizmos的颜色。 function OnDrawGizmosSelected() { Gizmos.color = Color.red; var direction = transform.TransformDirection(Vector3.forward) * 5; // 在物体的前方绘制一个5米长的线 Gizmos.DrawRay(transform.position, direction); } ◆ static var matrix : Matrix4x4 // 描述:设置用于渲染所有gizmos的矩阵。 类方法 ◆ Static function DrawCube(center:Vector3,size:Vector3):void // 描述:用center和size绘制一个立方体. Function OnDrawGizmosSelected(){ Gizmos.color=Color(1,0,0,5); // 在变换位置处绘制一个变透明的蓝色立方体 Gizmos.DrawCube(transform.position,Vector3(1,1,1)); } ◆ Static function DrawGUITexture(screenRect:Rect,texture:Texture,mat:Material=null):void // 描述:在屏幕坐标下绘制一个纹理。用于GUI背景。 ◆ Static function DrawGUITexture(screenRect:Rect,texture:Texture,leftBorder:int,rightBorder:int,topBorder:int,bottomBorder:int,mat:Material=null):void // 描述:在屏幕坐标下绘制一个纹理。用于GUI背景。 ◆ Static function Drawicon(center:Vector3,name:string):void // 描述:在世界位置center处绘制一个图标.这个图标被命名为name并放置在Assets/Gizmos文件夹或Unity.app/Resoutces文件夹.DrawIcon允许你在游戏中快速选择重要的物体。 在物体位置处绘制光源灯泡图标.因为我们在OnDrawGizmos函数内部调用它,在场景视图中 ,这个图标总是可点选的. function OnDrawGizmos(){ Gizmos DrawIcon(transform.position,”Light Gizmo.tiff”); } ◆ Static function DrawLine(from:Vector3,to:Vector3):void // 描述:绘制一条线从from到to. Var Larget:Transform; function OnDrawGizmosSelected(){ if(target != null) { Gizmos.color = Color.blue; //从transform到target绘制一条蓝色的线 Gizmos.DrawLine(transform.position,target.position); } } ◆ static function DrawRay(r:Ray):void static function DrawRay(from:Vector3,direction:Vector3):void // 描述:绘制一个射线从from开始到from + direction. ◆ function OnDrawGizmosSelected(){ Gizmos.color = Color.red; Direction = transform.TransformDirection(Vector3.forward)*5; Gizmos.DrawRay(transform.positon,direction); } ◆ Static function DrawSphere(center:Vector3,radius:flont):void // 描述:用center和randins绘制一个球体. Function OnDrawGizmosSelected(){ Gizmos.color = Color.yellow; // 在变换位置处绘制一个黄色的球体 Gizmos.DrawSphere(transtorm.position,1); } ◆ Static function DrawWireCube(center:Vector3, size: Vector3):void // 描述:用center和radius绘制一个线框立方体. Function OnDrawGizmosSelected(){ Gizmos.color = Color.yellow; //在变换位置处绘制一个黄色立方体 Gizmos.DrawWireCube (transtorm.position, Vector3(1,1,1)); } ◆ Static function DrawWireSphere(center:Vector3,radius:float):void // 描述:用center和radius绘制一个线框球体. Var explosionRadius = 5.0; Function OnDrawGizmosSelected(){ Gizmos.color = Color.white; //选中的时候显示爆炸路劲 Gizmos.DrawSphere(transtorm.position,explpsionRadius); }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值