添加了这个脚本后
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class MyScoll : MonoBehaviour,IBeginDragHandler,IEndDragHandler {
private ScrollRect scrollRect;
private float[] pageArray = new float[]{0,0.333f,0.666f,1};
// Use this for initialization
void Start () {
scrollRect = GetComponent<ScrollRect> ();
}
// Update is called once per frame
void Update () {
}
public void OnBeginDrag(PointerEventData eventData){
}
public void OnEndDrag(PointerEventData eventData){
float posX = scrollRect.horizontalNormalizedPosition;
print (posX);
int index = 0;
float offset = Mathf.Abs (pageArray [index] - posX);
for (int i = 0 ; i< pageArray.Length ; i++){
float offsetTemp = Mathf.Abs (pageArray [i] - posX);
if (offsetTemp < offset) {
index = i;
offset = offsetTemp;
}
}
}
}
UNITY 报错,提示
NullReferenceException: (null)
UnityEditor.SerializedObject..ctor (UnityEngine.Object[] objs, UnityEngine.Object context) (at C:/buildslave/unity/build/artifacts/generated/common/editor/SerializedPropertyBindings.gen.cs:87)
UnityEditor.Editor.GetSerializedObjectInternal () (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorBindings.gen.cs:193)
UnityEditor.Editor.get_serializedObject () (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorBindings.gen.cs:185)
UnityEditor.MaterialEditor.OnEnable () (at C:/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:1773)
点击后无法定位到是哪行代码出错
NullReferenceException: (null)
UnityEditor.SerializedObject..ctor (UnityEngine.Object[] objs, UnityEngine.Object context) (at C:/buildslave/unity/build/artifacts/generated/common/editor/SerializedPropertyBindings.gen.cs:87)
UnityEditor.Editor.GetSerializedObjectInternal () (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorBindings.gen.cs:193)
UnityEditor.Editor.get_serializedObject () (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorBindings.gen.cs:185)
UnityEditor.MaterialEditor.OnEnable () (at C:/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:1773)
这个错误提示并没有指定我们代码的错误行数在哪里,都是一些unity自己内置的代码的问题,这个错误信息是完整的吗