Hi… Having " NULL REFERENCE " Problem, even though the variable is set to ‘1’, its coming up somewhere as NULL - then in mid loading- I’m getting this error:
The main problem is now this:
I found another place the error has jumped to.
Fixed some things,but had an error in this next section (Line 99):
// GUI MATRIX
if(matrixAngle != previousAngle || matrixPosition != prevMatrixPosition) { //only calculate new Quaternion if angle changed
quat.eulerAngles = Vector3(0.0, 0.0, matrixAngle);
(It says the cause is x 2:
swipeCtrl.maxValue = 1;
and
var offset : float = swipeCtrl.smoothValue - Mathf.Round(swipeCtrl.smoothValue);
and the second problem.
NOTE: I have multiple scripts that are copied with different title names - but same programming - just changed the titles of the files, and the name of some variables to suite the multiple copies of this script.
NullReferenceException: Object reference not set to an instance of an object
ImageDisplay4.Awake () (at Assets/Scripts/ImageDisplay4.js:63)
UnityEngine.Object:Instantiate(Object)
$:MoveNext() (at Assets/viewer-scripts/LOADCONTROL.js:265)
Here is the main chunk of code thats having the problem…
//Set up SwipeControl
//swipeCtrl.partWidth = img.width;
swipeCtrl.maxValue = 1;
if(expandInputAreaToFullWidth) {
swipeCtrl.SetMouseRect(new Rect(-Screen.width * 0.5, imgRect.y, Screen.width, imgRect.height)); // Use image-height for the input-Rect, but full screen-width
} else {
swipeCtrl.SetMouseRect(imgRect); //Use the same Rect as the images for input
}
swipeCtrl.CalculateEdgeRectsFromMouseRect(imgRect);
swipeCtrl.Setup();
/*
//Determine center position of the Dots
if(dotRelativeCenterPos == Vector2.zero) dotRelativeCenterPos.y = imgRect.height * 0.5 + 14;
dotRelativeCenterPos = new Vector2((imgRect.x + imgRect.width * 0.5) + dotRelativeCenterPos.x, (imgRect.y + imgRect.height * 0.5) + dotRelativeCenterPos.y);
*/
if(centerMatrixOnScreen) {
matrixPosition.x += Mathf.Round(Screen.width * 0.5);
matrixPosition.y += Mathf.Round(Screen.height * 0.5)+176;//this is it adddown spawn extra space down
}
}
function OnGUI () {
// GUI MATRIX
if(matrixAngle != previousAngle || matrixPosition != prevMatrixPosition) { //only calculate new Quaternion if angle changed
quat.eulerAngles = Vector3(0.0, 0.0, matrixAngle);
previousAngle = matrixAngle;
matrix = Matrix4x4.TRS(matrixPosition, quat, Vector3.one); //If you're no longer tweaking
prevMatrixPosition = matrixPosition;
swipeCtrl.matrix = matrix; // Tell SwipeControl to use the same Matrix we use here
}
GUI.matrix = matrix;
// IMAGES
var offset : float = swipeCtrl.smoothValue - Mathf.Round(swipeCtrl.smoothValue);
var mainPos : float = imgRect.x - (offset * imgRect.width);
if(Mathf.Round(swipeCtrl.smoothValue) >= 0 && Mathf.Round(swipeCtrl.smoothValue) < 1) {
GUI.color.a = 1 - Mathf.Abs(offset);
GUI.DrawTexture(new Rect(mainPos, imgRect.y, imgRect.width, imgRect.height), img);//[Mathf.Round(swipeCtrl.smoothValue)]);
// GUI.DrawTexture(new Rect(mainPos, imgRect.y, imgRect.width, imgRect.height), img);//[Mathf.Round(swipeCtrl.smoothValue)]);
}
Thanks for the help, in advance…
Kris
F.Y.I. - I tried setting the first part (quoted above) to "0" (zero) - with NO Effect...
– djkr_1I appreciate that you deleted your answer. I wasn't saying you can't post your whole code, but to do it in your original question and to format it properly... at the end of your question, at the left, quite small and light gray there's a button 'edit'. If you click it, you can fix up your original post with more information. remove the old code. then paste the full new code. Select the full new code. Then hit the little 101010 button...
– SisterKy