public override void SafeAwake() { base.SafeAwake(); buildSurface = GetComponent <BuildSurface>(); colliderToggle = AddToggle("Collider", "collider", false); kinematicToggle = AddToggle("Kinematic", "kinematic", false); redSlider = AddSlider("red", "red", 1f, 0f, 1f); redSlider.ValueChanged += colorChanged; greenSlider = AddSlider("green", "green", 1f, 0f, 1f); greenSlider.ValueChanged += colorChanged; blueSlider = AddSlider("blue", "blue", 1f, 0f, 1f); blueSlider.ValueChanged += colorChanged; alphaSlider = AddSlider("Alpha", "Alpha", 1f, 0f, 1f); alphaSlider.ValueChanged += colorChanged; radiusSlider = AddSlider("Radius", "Radius", 1f, 0.1f, 1f); radiusSlider.ValueChanged += radiusChanged; buildSurface.material.ValueChanged += materialChanged; materialChanged(buildSurface.material.Value); StartCoroutine(wait()); IEnumerator wait() { //skinChanged(0); yield return(new WaitUntil(() => BB.Visual != null)); BB.Visual.ValueChanged += skinChanged; skinChanged(BB.Visual.Value); yield break; } #if DEBUG ConsoleController.ShowMessage("蒙皮块添加进阶属性"); #endif }
public override void OnSimulateStart_EnhancementEnabled() { base.OnSimulateStart_EnhancementEnabled(); buildSurface = GetComponent <BuildSurface>(); fragmentController = GetComponent <SurfaceFragmentController>(); if (colliderToggle.IsActive) { //buildSurface.BlockHealth.health = Mathf.Infinity; var ctr = fragmentController; ctr.fragments.ToList().ForEach(fra => fra.IsBroken = fra.IsIndependent = fra.HasOwnBody = true); var type = buildSurface.currentType; type.breakImpactSettings = BuildSurface.BreakImpactSettings.Disabled; type.breakable = type.burnable = type.dentable = false; type.fragmentBreakImpactThreshold = Mathf.Infinity; type.hasHealth = true; foreach (var joint in buildSurface.Joints) { joint.projectionMode = JointProjectionMode.PositionAndRotation; joint.projectionDistance = joint.projectionAngle = 0f; joint.breakForce = Mathf.Infinity; joint.breakTorque = Mathf.Infinity; } var cols = transform.FindChild("SimColliders").GetComponentsInChildren <Collider>(); foreach (var col in cols) { col.isTrigger = true; } var mcols = gameObject.GetComponentsInChildren <MeshCollider>(); foreach (var mcol in mcols) { mcol.isTrigger = mcol.convex = true; } StartCoroutine(wait()); IEnumerator wait() { for (int i = 0; i < 3; i++) { yield return(0); } yield break; } } if (kinematicToggle.IsActive) { StartCoroutine(wait1()); IEnumerator wait1() { for (int i = 0; i < 3; i++) { yield return(0); } buildSurface.Rigidbody.isKinematic = true; buildSurface.gameObject.isStatic = true; yield break; } } }