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
  Distance travelled across multiple splines jh092 1 7 02-23-2024, 09:44 AM
Last Post: _Aka_
  Best practice for controllers slowing down/speeding up along the spline Curry 1 5 08-06-2023, 09:47 PM
Last Post: _Aka_
  Moving object down or up the spline using gravity velikizlivuk 6 19 07-26-2023, 10:06 PM
Last Post: _Aka_
  Multiple Splines and Generators Performantly for Road System drock 1 6 07-17-2023, 10:31 AM
Last Post: _Aka_

Forum Jump: