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_


 
 
 
 
 

你可能感兴趣的:(unity3d 之-error记)