Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Moving multiple controllers at once
#17
Sorry but I must bother you one more time. This code gives no errors in Visual B.
Code:
private void OnEnable()
       {
           List<SplineController> selectedItems = Selection.transforms.Select(t => t.gameObject.GetComponent<SplineController>()).Where(c => c != null).ToList();
          
           if (selectedItems.Count > 1)
           {
               index = 0;
               controllers = selectedItems.ToArray();
               makeWindow = true;
               foreach(SplineController checkController in controllers)
               {
                   orgPos[index] = checkController.AbsolutePosition;
                   maxPos[index] = checkController.Spline.Length;
                   Debug.Log(orgPos[index]);
                   Debug.Log(maxPos[index]);
                   Debug.Log(controllers[index]);
                   index++;
               }
               
           }
But once in Unity I get this when I select objects with controllers.
Quote:NullReferenceException: Object reference not set to an instance of an object
FluffyUnderware.CurvyEditor.Controllers.MoveMultipleControllers.OnEnable () (at Assets/Game Assets/Editor/MoveMultipleControllers.cs:42)
Line 42 is the first in the loop.

I don't get this, doesn't "List<SplineController> selectedItems" contain the controllers or is it something else I've done wrong?  Huh
Reply


Messages In This Thread
Moving multiple controllers at once - by Lupp_ - 01-15-2020, 07:46 PM
RE: Moving multiple controllers at once - by Lupp_ - 02-05-2020, 12:49 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Connecting Multiple Spline Nodes Issue Ritesh Kadam 1 161 08-22-2026, 11:24 PM
Last Post: _Aka_
  Updated package in 2022 LTS resulted in multiple errors scr33ner 2 2,086 01-13-2025, 09:32 AM
Last Post: _Aka_
  Moving Platform Kokoriko49 8 5,274 09-23-2024, 09:20 AM
Last Post: _Aka_
  Distance travelled across multiple splines jh092 1 1,855 02-23-2024, 09:44 AM
Last Post: _Aka_

Forum Jump: