Guest User

com.lee23.GenerateBasePrefabCommand StripComponents example

a guest
Feb 10th, 2025
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.38 KB | None | 0 0
  1. private static void StripComponents(GameObject gameObject)
  2. {
  3.     foreach (var ghostBase in gameObject.GetComponentsInChildren<DeactivateInGhostBase>())
  4.     {
  5.         ghostBase.gameObject.SetActive(false);
  6.     }
  7.    
  8.     foreach (var baseSurfaceModel in gameObject.GetComponentsInChildren<BaseSurfaceModel>())
  9.     {
  10.         baseSurfaceModel.aboveWaterModel?.SetActive(false);
  11.         baseSurfaceModel.underWaterModel?.SetActive(true);
  12.         Object.DestroyImmediate(baseSurfaceModel);
  13.     }
  14.  
  15.     switch (gameObject.name)
  16.     {
  17.         case "BaseCorridorCoverIShapeBottomIntOpened(Clone)":
  18.         case "BaseCorridorCoverTShapeBottomIntOpened(Clone)":
  19.             gameObject.transform.Find("collisions").gameObject.SetActive(false);
  20.             break;
  21.         case "BaseCorridorLadderBottom(Clone)":
  22.             gameObject.transform.Find("logic").gameObject.SetActive(false);
  23.             break;
  24.         case "BaseMoonpool(Clone)":
  25.             gameObject.transform.Find("entrance").gameObject.SetActive(false);
  26.             gameObject.transform.Find("Flood_BaseMoonPool").gameObject.SetActive(false);
  27.             var launchBay = gameObject.transform.Find("Launchbay_cinematic");
  28.             foreach (Transform child in launchBay)
  29.             {
  30.                 if (child.gameObject.name != "moon_pool_anim") child.gameObject.SetActive(false);
  31.             }
  32.             break;
  33.         case "BaseObservatory(Clone)":
  34.             Object.DestroyImmediate(gameObject.GetComponent<ObservatoryAmbientSound>());
  35.             break;
  36.         case "BaseCorridorHatch(Clone)":
  37.             gameObject.transform.Find("underWater/collisions").gameObject.SetActive(false);
  38.             break;
  39.     }
  40.    
  41.     Object.DestroyImmediate(gameObject.GetComponentInChildren<BaseLadder>());
  42.  
  43.     // OPTIONAL, helps with bright lighting.
  44.     // If you do this, I recommend you add your own SkyApplier to the prefab root through code.
  45.    
  46.     /*
  47.     var skyApplierComponents = gameObject.GetComponents<SkyApplier>();
  48.     foreach (var skyApplier in skyApplierComponents)
  49.     {
  50.         Object.DestroyImmediate(skyApplier);
  51.     }
  52.  
  53.  
  54.     var renderers = gameObject.GetComponentsInChildren<Renderer>();
  55.     foreach (var renderer in renderers)
  56.     {
  57.         foreach (var material in renderer.materials)
  58.         {
  59.             material.SetFloat("_SpecInt", material.GetFloat("_SpecInt") * 0.05f);
  60.         }
  61.     }
  62.     */
  63. }
Advertisement
Add Comment
Please, Sign In to add comment