public FairingSlice(ModuleSimpleAdjustableFairing parent, int index) { this.parent = parent; GameObject gameObject = new GameObject(OBJECT_NAME); rootTransform = gameObject.transform; rotation = Quaternion.AngleAxis(360f / parent.numSlices * index, parent.axis); rootTransform.NestToParent(parent.FairingRootTransform); rootTransform.localRotation = rotation; coneTransform = UnityEngine.Object.Instantiate(parent.PrefabConeTransform); coneTransform.NestToParent(rootTransform); coneTransform.gameObject.SetActive(true); coneTransform.SetCollidersEnabled(parent.FairingCollidersEnabled); coneTransform.localScale *= parent.scale; }
public override void OnAwake() { base.OnAwake(); // Get coneData and wallData from prefab since they are non-serializable if (part.partInfo != null) { ModuleSimpleAdjustableFairing module = part.partInfo.partPrefab?.FindModuleImplementing <ModuleSimpleAdjustableFairing>(); if (module == null) { this.LogError("Cannot find module on prefab!"); } else { WallData = part.partInfo.partPrefab?.FindModuleImplementing <ModuleSimpleAdjustableFairing>()?.WallData; ConeData = part.partInfo.partPrefab?.FindModuleImplementing <ModuleSimpleAdjustableFairing>()?.ConeData; } } }