Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Suggestion / Idea  Problem with the Obi Solver Structure
#3
Hey,

Adding a solver to the prefab stage was much easier than I expected. Add this code anywhere in ObiActor.cs, now everytime you edit an actor prefab the prefab stage contains a solver at its root. Will clean this up a bit and include it in 5.0.1 for next week.

Code:
protected void Awake()
       {
#if UNITY_EDITOR

           // Check if this script's GameObject is in a PrefabStage
           var prefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetPrefabStage(gameObject);

           if (prefabStage != null)
           {
               // Check if parent is null to ensure we are handling the root
               if (gameObject.transform.parent != null)
                   return;

               // Add our own environment root and move it to the PrefabStage scene
               var newParent = new GameObject("ObiSolver (Environment)",typeof(ObiSolver), typeof(ObiLateFixedUpdater));
               newParent.GetComponent<ObiLateFixedUpdater>().solvers.Add(newParent.GetComponent<ObiSolver>());
               UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(newParent, gameObject.scene);
               transform.parent = newParent.transform;
           }
#endif
       }
Reply


Messages In This Thread
RE: Problem with the Obi Solver Structure - by josemendez - 21-11-2019, 07:13 PM