public void Start() { /*Plane groundPlane = (Plane) GameObject.FindObjectOfType(typeof(Plane)); * if (groundPlane == null) Debug.LogError("Plane not found. Please add a plane mesh to your stage prefab!");*/ groundLayer = LayerMask.NameToLayer("Ground"); groundMask = 1 << groundLayer; myControlsScript = GetComponent <ControlsScript>(); character = myControlsScript.character; myHitBoxesScript = character.GetComponent <HitBoxesScript>(); myMoveSetScript = character.GetComponent <MoveSetScript>(); appliedGravity = myControlsScript.myInfo.physics.weight * UFE.config.gravity; }
public Vector3 TestCollision(BlockArea blockableArea) { HurtBox hurtBox = new HurtBox(); hurtBox.position = blockableArea.position; hurtBox.shape = blockableArea.shape; hurtBox.rect = blockableArea.rect; hurtBox.followXBounds = blockableArea.followXBounds; hurtBox.followYBounds = blockableArea.followYBounds; hurtBox.radius = blockableArea.radius; hurtBox.offSet = blockableArea.offSet; // We use throw confirmation type so the engine doesn't register the state of the stroke hitbox as hit return(HitBoxesScript.TestCollision(this.hitBoxes, new HurtBox[] { hurtBox }, HitConfirmType.Hit, controlsScript.mirror)); }
public FPVector[] TestCollision(HurtBox[] hurtBoxes, HitConfirmType hitConfirmType) { if (isHit && hitConfirmType == HitConfirmType.Hit) { return(new FPVector[0]); } foreach (HitBox hitbox in this.hitBoxes) { if (hitbox.followXBounds || hitbox.followYBounds) { hitbox.rendererBounds = GetBounds(); } } return(HitBoxesScript.TestCollision(worldTransform.position, this.hitBoxes, hurtBoxes, hitConfirmType, controlsScript.mirror)); }
public Vector3[] TestCollision(HurtBox[] hurtBoxes, HitConfirmType hitConfirmType) { if (isHit && hitConfirmType == HitConfirmType.Hit) { return new Vector3[] { } } ; foreach (HitBox hitbox in this.hitBoxes) { if (hitbox.followXBounds || hitbox.followYBounds) { hitbox.rendererBounds = GetBounds(); } } return(HitBoxesScript.TestCollision(this.hitBoxes, hurtBoxes, hitConfirmType, controlsScript.mirror)); }
public Vector3 TestCollision(HurtBox[] hurtBoxes, HitConfirmType hitConfirmType) { if (isHit && hitConfirmType == HitConfirmType.Hit) { return(Vector3.zero); } foreach (HitBox hitbox in this.hitBoxes) { if (hitbox.followXBounds || hitbox.followYBounds) { hitbox.rendererBounds = GetBounds(); } } /*Vector3 result = HitBoxesScript.TestCollision(this.hitBoxes, hurtBoxes, hitConfirmType, controlsScript.mirror); * if (result == Vector3.zero) { * foreach (HitBox hitBox in hitBoxes) { * if (hitBox.state == 1) hitBox.state = 0; * } * }*/ return(HitBoxesScript.TestCollision(this.hitBoxes, hurtBoxes, hitConfirmType, controlsScript.mirror)); }
public void DoFixedUpdate() { if (isHit > 0) { isHit -= Time.fixedDeltaTime; return; } // Check if both controllers are ready AbstractInputController p1InputController = UFE.GetPlayer1Controller(); AbstractInputController p2InputController = UFE.GetPlayer2Controller(); if (p1InputController == null || !p1InputController.isReady || p2InputController == null || !p2InputController.isReady) { return; } if (UFE.freeCamera) { return; } transform.position += (movement * Time.fixedDeltaTime); hurtBox.position = gameObject.transform.position; if (projectileRenderer != null && (hurtBox.followXBounds || hurtBox.followYBounds)) { hurtBox.rendererBounds = GetBounds(); hitBox.rendererBounds = GetBounds(); } blockableArea.position = transform.position; if (!opControlsScript.isBlocking && !opControlsScript.blockStunned && opControlsScript.currentSubState != SubStates.Stunned && opHitBoxesScript.TestCollision(blockableArea) != Vector3.zero) { opControlsScript.CheckBlocking(true); } if (data.projectileCollision) { if (opControlsScript.projectiles.Count > 0) { foreach (ProjectileMoveScript projectile in opControlsScript.projectiles) { if (projectile == null) { continue; } if (projectile.hitBox == null) { continue; } if (projectile.hurtBox == null) { continue; } if (HitBoxesScript.TestCollision(new HitBox[] { projectile.hitBox }, new HurtBox[] { hurtBox }, HitConfirmType.Hit, mirror) != Vector3.zero) { if (data.impactPrefab != null) { GameObject hitEffect = (GameObject)Instantiate(data.impactPrefab, transform.position, Quaternion.Euler(0, 0, data.directionAngle)); UFE.DelaySynchronizedAction(delegate(){ try{ Destroy(hitEffect); }catch {} }, data.impactDuration); } totalHits--; if (totalHits <= 0) { destroyMe = true; } isHit = spaceBetweenHits; transform.Translate(movement * -1 * Time.fixedDeltaTime); break; } } } } if (opHitBoxesScript.TestCollision(new HurtBox[] { hurtBox }, HitConfirmType.Hit) != Vector3.zero && opControlsScript.ValidateHit(hit)) { if (data.impactPrefab != null) { GameObject hitEffect = (GameObject)Instantiate(data.impactPrefab, transform.position, Quaternion.Euler(0, 0, data.directionAngle)); UFE.DelaySynchronizedAction(delegate(){ try{ Destroy(hitEffect); }catch {} }, data.impactDuration); } totalHits--; if (totalHits <= 0) { UFE.DelaySynchronizedAction(delegate(){ try{ Destroy(gameObject); }catch {} }, (float)(2 / UFE.config.fps)); } if (opControlsScript.currentSubState != SubStates.Stunned && opControlsScript.isBlocking && opControlsScript.TestBlockStances(hit.hitType)) { myControlsScript.AddGauge(data.gaugeGainOnBlock); opControlsScript.AddGauge(data.opGaugeGainOnBlock); opControlsScript.GetHitBlocking(hit, 20, transform.position); if (data.moveLinkOnBlock != null) { myControlsScript.CastMove(data.moveLinkOnBlock, true, data.forceGrounded); } } else if (opControlsScript.potentialParry > 0 && opControlsScript.TestParryStances(hit.hitType)) { opControlsScript.AddGauge(data.opGaugeGainOnParry); opControlsScript.GetHitParry(hit, 20, transform.position); if (data.moveLinkOnParry != null) { myControlsScript.CastMove(data.moveLinkOnParry, true, data.forceGrounded); } } else { myControlsScript.AddGauge(data.gaugeGainOnHit); opControlsScript.AddGauge(data.opGaugeGainOnHit); opControlsScript.GetHit(hit, 30, Vector3.zero); if (data.moveLinkOnStrike != null) { myControlsScript.CastMove(data.moveLinkOnStrike, true, data.forceGrounded); } } isHit = opControlsScript.GetHitFreezingTime(data.hitStrength) * 1.2f; opControlsScript.CheckBlocking(false); } }
public void DoFixedUpdate() { // If both controllers aren't ready, ignore the player input if (!UFE.GetPlayer1Controller().isReady || !UFE.GetPlayer2Controller().isReady) return; // Training Mode if ((playerNum == 1 && UFE.gameMode == GameMode.TrainingRoom && UFE.config.trainingModeOptions.p1Life == LifeBarTrainingMode.Refill) || (playerNum == 2 && UFE.gameMode == GameMode.TrainingRoom && UFE.config.trainingModeOptions.p2Life == LifeBarTrainingMode.Refill)) { if (!UFE.FindDelaySynchronizedAction(this.RefillLife)) UFE.DelaySynchronizedAction(this.RefillLife, UFE.config.trainingModeOptions.refillTime); } if ((playerNum == 1 && UFE.gameMode == GameMode.TrainingRoom && UFE.config.trainingModeOptions.p1Gauge == LifeBarTrainingMode.Refill) || (playerNum == 2 && UFE.gameMode == GameMode.TrainingRoom && UFE.config.trainingModeOptions.p2Gauge == LifeBarTrainingMode.Refill)) { if (!UFE.FindDelaySynchronizedAction(this.RefillGauge)) UFE.DelaySynchronizedAction(this.RefillGauge, UFE.config.trainingModeOptions.refillTime); } if (UFE.gameMode == GameMode.TrainingRoom && myInfo.currentGaugePoints < myInfo.maxGaugePoints && ((playerNum == 1 && UFE.config.trainingModeOptions.p1Gauge == LifeBarTrainingMode.Infinite) || (playerNum == 2 && UFE.config.trainingModeOptions.p2Gauge == LifeBarTrainingMode.Infinite))) RefillGauge(); if (UFE.gameMode == GameMode.TrainingRoom && myInfo.currentLifePoints < myInfo.lifePoints && ((playerNum == 1 && UFE.config.trainingModeOptions.p1Life == LifeBarTrainingMode.Infinite) || (playerNum == 2 && UFE.config.trainingModeOptions.p2Life == LifeBarTrainingMode.Infinite))) RefillLife(); // Debugger if (debugger != null && UFE.config.debugOptions.debugMode){ debugger.text = ""; if (UFE.config.debugOptions.debugMode) { debugger.text += "-----Character Info-----\n"; if (debugInfo.lifePoints) debugger.text += "Life Points: " + myInfo.currentLifePoints + "\n"; if (debugInfo.position) debugger.text += "Position: " + transform.position + "\n"; if (debugInfo.currentState) debugger.text += "State: " + currentState + "\n"; if (debugInfo.currentSubState) debugger.text += "Sub State: " + currentSubState + "\n"; if (debugInfo.stunTime && stunTime > 0) debugger.text += "Stun Time: " + stunTime + "\n"; if (opControlsScript != null && opControlsScript.comboHits > 0) { debugger.text += "Current Combo\n"; if (debugInfo.comboHits) debugger.text += "- Total Hits: "+ opControlsScript.comboHits + "\n"; if (debugInfo.comboDamage) { debugger.text += "- Total Damage: " + opControlsScript.comboDamage + "\n"; debugger.text += "- Hit Damage: " + opControlsScript.comboHitDamage + "\n"; } } // Other uses //if (potentialParry > 0) debugger.text += "Parry Window: "+ potentialParry + "\n"; //debugger.text += "Air Jumps: "+ myPhysicsScript.currentAirJumps + "\n"; if (UFE.config.debugOptions.p1DebugInfo.currentMove && currentMove != null) { debugger.text += "Move: "+ currentMove.name + " ("+ currentMove.currentFrame +"/"+ currentMove.totalFrames +") \n"; /*if (currentMove.chargeMove) { debugger.text += "First Input Charge: "+ myMoveSetScript.chargeValues[currentMove.buttonSequence[0]] + "\n"; }*/ //debugger.text += "StartupFrames: "+ currentMove.moveClassification.startupSpeed +" \n"; } } if (aiDebugger != null && debugInfo.aiWeightList) debugger.text += aiDebugger; } // Once per game if (opHitBoxesScript == null) { opControlsScript = opponent.GetComponent<ControlsScript>(); opPhysicsScript = opponent.GetComponent<PhysicsScript>(); opHitBoxesScript = opponent.GetComponentInChildren<HitBoxesScript>(); opInfo = opControlsScript.myInfo; if (myInfo.enableAlternativeColor){ if (gameObject.name == "Player2" && character.name == opControlsScript.character.name){ // Alternative Costume Renderer[] charRenders = character.GetComponentsInChildren<Renderer>(); foreach(Renderer charRender in charRenders){ charRender.material.color = myInfo.alternativeColor; //charRender.material.shader = Shader.Find("VertexLit"); //charRender.material.SetColor("_Emission", myInfo.alternativeColor); } } } Renderer[] charRenderers = character.GetComponentsInChildren<Renderer>(); List<Shader> shaderList = new List<Shader>(); List<Color> colorList = new List<Color>(); foreach(Renderer char_rend in charRenderers){ //if (char_rend.material.HasProperty("color") && char_rend.material.HasProperty("shader")){ shaderList.Add(char_rend.material.shader); colorList.Add(char_rend.material.color); //} } normalShaders = shaderList.ToArray(); normalColors = colorList.ToArray(); myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.idle); } // Once per round if ((gameObject.name == "Player1" && !introPlayed && currentMove == null) || (gameObject.name == "Player2" && !introPlayed && opControlsScript.introPlayed && currentMove == null)) { KillCurrentMove(); CastMove(myMoveSetScript.intro, true, true, false); if (currentMove == null) { introPlayed = true; UFE.CastNewRound(); } } // Resolve move resolveMove(); // Check inputs translateInputs(inputController); // Validate rotation validateRotation(); // Input Viewer List<InputReferences> inputList = new List<InputReferences>(); foreach (InputReferences inputRef in inputController.inputReferences){ if (debugger != null && UFE.config.debugOptions.debugMode && debugInfo.inputs){ debugger.text += inputRef.inputButtonName + " - "+ inputRef.heldDown + "\n"; } if (inputRef.heldDown > 0 && inputRef.heldDown <= (2f/(float)UFE.config.fps)){ inputList.Add(inputRef); } } UFE.CastInput(inputList.ToArray(), playerNum); // Force character local position if (ignoreAnimationTransform && (currentMove == null || !currentMove.applyRootMotion)) character.transform.localPosition = new Vector3(0, 0, 0); // Force stand state if (!myPhysicsScript.freeze && !isDead && currentSubState != SubStates.Stunned && introPlayed && myPhysicsScript.IsGrounded() && !myPhysicsScript.IsMoving() && currentMove == null && !myMoveSetScript.IsBasicMovePlaying(myMoveSetScript.basicMoves.idle) && !myMoveSetScript.IsAnimationPlaying("fallStraight") && isAxisRested(inputController) && !myPhysicsScript.isTakingOff && !myPhysicsScript.isLanding && !blockStunned && currentState != PossibleStates.Crouch && !isBlocking ){ myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.idle); currentState = PossibleStates.Stand; currentSubState = SubStates.Resting; if (UFE.config.blockOptions.blockType == BlockType.AutoBlock && myMoveSetScript.basicMoves.blockEnabled) potentialBlock = true; } if (myMoveSetScript.IsAnimationPlaying("idle") && !UFE.config.lockInputs && !UFE.config.lockMovements) { afkTimer += Time.fixedDeltaTime; if (afkTimer >= myMoveSetScript.basicMoves.idle.restingClipInterval) { afkTimer = 0; int clipNum = Mathf.RoundToInt(Random.Range(2, 6)); if (myMoveSetScript.AnimationExists("idle_" + clipNum)) { myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.idle, "idle_" + clipNum, false); } } } else { afkTimer = 0; } // Character colliders based on collision mass and body colliders normalizedDistance = Mathf.Clamp01(Vector3.Distance(opponent.transform.position, transform.position) / UFE.config.cameraOptions.maxDistance); if (!ignoreCollisionMass && !opControlsScript.ignoreCollisionMass) { float pushForce = myHitBoxesScript.TestCollision(opHitBoxesScript.hitBoxes); if (pushForce > 0) { if (transform.position.x < opponent.transform.position.x) { transform.Translate(new Vector3(-.1f * pushForce, 0, 0)); }else{ transform.Translate(new Vector3(.1f * pushForce, 0, 0)); } if (opponent.transform.position.x == UFE.config.selectedStage.rightBoundary){ opponent.transform.Translate(new Vector3(-.2f * pushForce, 0, 0)); } } pushForce = myInfo.physics.groundCollisionMass - Vector3.Distance(transform.position, opponent.transform.position); if (pushForce > 0) { if (transform.position.x < opponent.transform.position.x) { transform.Translate(new Vector3(-.5f * pushForce, 0, 0)); }else{ transform.Translate(new Vector3(.5f * pushForce, 0, 0)); } if (opponent.transform.position.x == UFE.config.selectedStage.rightBoundary){ opponent.transform.Translate(new Vector3(-.2f * pushForce, 0, 0)); } } } // Shake character if (shakeDensity > 0) { shakeDensity -= Time.fixedDeltaTime; if (myHitBoxesScript.isHit && myPhysicsScript.freeze){ if (shakeCharacter) shake(); if (shakeCamera) shakeCam(); }else{ if (UFE.config.bounceOptions.shakeCamOnBounce && myPhysicsScript.isBouncing) shakeCam(); } }else if (shakeDensity < 0) { shakeDensity = 0; shakeCamera = false; shakeCharacter = false; } // Validate Parry if (potentialParry > 0){ potentialParry -= Time.fixedDeltaTime; if (potentialParry <= 0) potentialParry = 0; } // Update head movement if (headLookScript != null && opHitBoxesScript != null) headLookScript.target = opHitBoxesScript.GetPosition(myInfo.headLook.target); // Execute Move if (currentMove != null) ReadMove(currentMove); // Apply Stun if ((currentSubState == SubStates.Stunned || blockStunned) && stunTime > 0 && !myPhysicsScript.freeze && !isDead) ApplyStun(); // Apply Forces myPhysicsScript.ApplyForces(currentMove); }
void Start() { if (gameObject.name == "Player1") { transform.position = new Vector3(UFE.config.roundOptions.p1XPosition, .009f, 0); opponent = GameObject.Find("Player2"); if (UFE.config.player1Character == null) Debug.LogError("Player 1 character not found! Make sure you have set the characters correctly in the Global Editor"); myInfo = (CharacterInfo) Instantiate(UFE.config.player1Character); UFE.config.player1Character = myInfo; debugger = UFE.debugger1; mirror = -1; playerNum = 1; inputController = UFE.GetPlayer1Controller(); debugInfo = UFE.config.debugOptions.p1DebugInfo; }else{ transform.position = new Vector3(UFE.config.roundOptions.p2XPosition, .009f, 0); opponent = GameObject.Find("Player1"); if (UFE.config.player2Character == null) Debug.LogError("Player 2 character not found! Make sure you have set the characters correctly in the Global Editor"); myInfo = (CharacterInfo) Instantiate(UFE.config.player2Character); UFE.config.player2Character = myInfo; debugger = UFE.debugger2; mirror = 1; playerNum = 2; inputController = UFE.GetPlayer2Controller(); debugInfo = UFE.config.debugOptions.p2DebugInfo; } myInfo.currentLifePoints = (float)myInfo.lifePoints; if (myInfo.characterPrefab == null) Debug.LogError("Character prefab for "+ gameObject.name +" not found. Make sure you have selected a prefab character in the Character Editor"); character = (GameObject) Instantiate(myInfo.characterPrefab); character.transform.parent = transform; character.AddComponent<MoveSetScript>(); standardYRotation = character.transform.rotation.eulerAngles.y; myPhysicsScript = GetComponent<PhysicsScript>(); myMoveSetScript = character.GetComponent<MoveSetScript>(); myHitBoxesScript = character.GetComponent<HitBoxesScript>(); cameraScript = transform.parent.GetComponent<CameraScript>(); myHitBoxesScript.controlsScript = this; if (myInfo.headLook.enabled){ character.AddComponent<HeadLookScript>(); headLookScript = character.GetComponent<HeadLookScript>(); headLookScript.segments = myInfo.headLook.segments; headLookScript.nonAffectedJoints = myInfo.headLook.nonAffectedJoints; headLookScript.effect = myInfo.headLook.effect; headLookScript.overrideAnimation = !myInfo.headLook.overrideAnimation; foreach(BendingSegment segment in headLookScript.segments) { segment.firstTransform = myHitBoxesScript.GetTransform(segment.bodyPart).parent.transform; segment.lastTransform = myHitBoxesScript.GetTransform(segment.bodyPart); } foreach(NonAffectedJoints nonAffectedJoint in headLookScript.nonAffectedJoints) nonAffectedJoint.joint = myHitBoxesScript.GetTransform(nonAffectedJoint.bodyPart); } if (gameObject.name == "Player2") { testCharacterRotation(100, true); UFE.FireGameBegins(); } if (UFE.config.roundOptions.allowMovement) { UFE.config.lockMovements = false; }else{ UFE.config.lockMovements = true; } }
public override void UFEFixedUpdate() { if (!this.gameObject.activeInHierarchy || destroyMe) { return; } if (isHit > 0) { isHit -= UFE.fixedDeltaTime; return; } // Check if both controllers are ready if (UFE.freezePhysics) { return; } // Update Fixed Point Transform fpTransform.position += (movement * UFE.fixedDeltaTime); // Test Outbounds if (fpTransform.position.x > UFE.config.selectedStage._rightBoundary + 5 || fpTransform.position.x < UFE.config.selectedStage._leftBoundary - 5) { destroyMe = true; return; } // Get Auto Bounds hurtBox.position = fpTransform.position; if (projectileRenderer != null && (hurtBox.followXBounds || hurtBox.followYBounds)) { hurtBox.rendererBounds = GetBounds(); hitBox.rendererBounds = GetBounds(); } // Check Block Area Contact blockableArea.position = fpTransform.position; if (!opControlsScript.isBlocking && !opControlsScript.blockStunned && opControlsScript.currentSubState != SubStates.Stunned && opHitBoxesScript.TestCollision(blockableArea).Length > 0) { opControlsScript.CheckBlocking(true); } // Test Collision with Opponent's Projectiles if (data.projectileCollision) { if (opControlsScript.projectiles.Count > 0) { foreach (ProjectileMoveScript projectile in opControlsScript.projectiles) { if (projectile == null) { continue; } if (projectile.hitBox == null) { continue; } if (projectile.hurtBox == null) { continue; } if (HitBoxesScript.TestCollision(projectile.fpTransform.position, new HitBox[] { projectile.hitBox }, new HurtBox[] { hurtBox }, HitConfirmType.Hit, mirror).Length > 0) { ProjectileHit(); projectile.ProjectileHit(); break; } } } } // Test Collision with Opponent FPVector[] collisionVectors = (opHitBoxesScript.TestCollision(new HurtBox[] { hurtBox }, HitConfirmType.Hit)); if (collisionVectors.Length > 0 && opControlsScript.ValidateHit(hit)) { ProjectileHit(); //if (data.impactPrefab != null){ // GameObject hitEffect = UFE.SpawnGameObject(data.impactPrefab, fpTransform.position.ToVector(), Quaternion.Euler(0, 0, data.directionAngle), Mathf.RoundToInt(data.impactDuration * UFE.config.fps)); //} //totalHits --; //if (totalHits <= 0){ // this.destroyMe = true; //} //isHit = opControlsScript.GetHitFreezingTime(data.hitStrength) * 1.2f; if (opControlsScript.currentSubState != SubStates.Stunned && opControlsScript.isBlocking && opControlsScript.TestBlockStances(hit.hitType)) { myControlsScript.AddGauge(data.gaugeGainOnBlock); opControlsScript.AddGauge(data.opGaugeGainOnBlock); opControlsScript.GetHitBlocking(hit, 20, collisionVectors); if (data.moveLinkOnBlock != null) { myControlsScript.CastMove(data.moveLinkOnBlock, true, data.forceGrounded); } } else if (opControlsScript.potentialParry > 0 && opControlsScript.TestParryStances(hit.hitType)) { opControlsScript.AddGauge(data.opGaugeGainOnParry); opControlsScript.GetHitParry(hit, 20, collisionVectors); if (data.moveLinkOnParry != null) { myControlsScript.CastMove(data.moveLinkOnParry, true, data.forceGrounded); } } else { myControlsScript.AddGauge(data.gaugeGainOnHit); opControlsScript.AddGauge(data.opGaugeGainOnHit); /*if (data.obeyDirectionalHit){ * hit._pushForce.x *= directionVector.x; * }*/ if (data.hitEffectsOnHit) { opControlsScript.GetHit(hit, 30, collisionVectors, data.obeyDirectionalHit); } else { opControlsScript.GetHit(hit, 30, new FPVector[0], data.obeyDirectionalHit); } if (data.moveLinkOnStrike != null) { myControlsScript.CastMove(data.moveLinkOnStrike, true, data.forceGrounded); } } opControlsScript.CheckBlocking(false); } // Update Unity Transform transform.position = fpTransform.position.ToVector(); }
public override void SetHoverIndex(int player, int characterIndex) { if (!this.closing) { int maxCharacterIndex = this.GetMaxCharacterIndex(); this.p1HoverIndex = Mathf.Clamp(this.p1HoverIndex, 0, maxCharacterIndex); this.p2HoverIndex = Mathf.Clamp(this.p2HoverIndex, 0, maxCharacterIndex); base.SetHoverIndex(player, characterIndex); if (characterIndex >= 0 && characterIndex <= maxCharacterIndex) { UFE3D.CharacterInfo character = this.selectableCharacters[characterIndex]; // First, update the big portrait or the character 3D model (depending on the Display Mode) if (player == 1) { if (this.namePlayer1 != null) { this.namePlayer1.text = character.characterName; } if (this.displayMode == DisplayMode.CharacterPortrait) { if (this.portraitPlayer1 != null) { this.portraitPlayer1.sprite = Sprite.Create( character.profilePictureBig, new Rect(0f, 0f, character.profilePictureBig.width, character.profilePictureBig.height), new Vector2(0.5f * character.profilePictureBig.width, 0.5f * character.profilePictureBig.height) ); } } else { UFE3D.CharacterInfo characterInfo = UFE.config.characters[characterIndex]; if (this.gameObjectPlayer1 != null) { GameObject.Destroy(this.gameObjectPlayer1); } AnimationClip clip = characterInfo.selectionAnimation != null ? characterInfo.selectionAnimation : characterInfo.moves[0].basicMoves.idle.animMap[0].clip; if (characterInfo.characterPrefabStorage == StorageMode.Prefab) { this.gameObjectPlayer1 = GameObject.Instantiate(characterInfo.characterPrefab); } else { this.gameObjectPlayer1 = GameObject.Instantiate(Resources.Load <GameObject>(characterInfo.prefabResourcePath)); } //this.gameObjectPlayer1 = GameObject.Instantiate(characterInfo.characterPrefab); this.gameObjectPlayer1.transform.position = this.positionPlayer1; this.gameObjectPlayer1.transform.SetParent(this.transform, true); HitBoxesScript hitBoxes = this.gameObjectPlayer1.GetComponent <HitBoxesScript>(); if (hitBoxes != null) { foreach (HitBox hitBox in hitBoxes.hitBoxes) { if (hitBox != null && hitBox.bodyPart != BodyPart.none && hitBox.position != null) { hitBox.position.gameObject.SetActive(hitBox.defaultVisibility); } } } if (characterInfo.animationType == AnimationType.Legacy) { Animation animation = this.gameObjectPlayer1.GetComponent <Animation>(); if (animation == null) { animation = this.gameObjectPlayer1.AddComponent <Animation>(); } animation.AddClip(clip, "Idle"); animation.wrapMode = WrapMode.Loop; animation.Play("Idle"); } else { Animator animator = this.gameObjectPlayer1.GetComponent <Animator>(); if (animator == null) { animator = this.gameObjectPlayer1.AddComponent <Animator>(); } AnimatorOverrideController overrideController = new AnimatorOverrideController(); overrideController.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("MC_Controller"); overrideController["State2"] = clip; animator.avatar = characterInfo.avatar; animator.applyRootMotion = characterInfo.applyRootMotion; animator.runtimeAnimatorController = overrideController; animator.Play("State2"); } } } else if (player == 2) { if (this.namePlayer2 != null) { this.namePlayer2.text = character.characterName; } if (this.displayMode == DisplayMode.CharacterPortrait) { if (this.portraitPlayer2 != null) { this.portraitPlayer2.sprite = Sprite.Create( character.profilePictureBig, new Rect(0f, 0f, character.profilePictureBig.width, character.profilePictureBig.height), new Vector2(0.5f * character.profilePictureBig.width, 0.5f * character.profilePictureBig.height) ); } } else { UFE3D.CharacterInfo characterInfo = UFE.config.characters[characterIndex]; if (this.gameObjectPlayer2 != null) { GameObject.Destroy(this.gameObjectPlayer2); } if (UFE.gameMode != GameMode.StoryMode) { AnimationClip clip = characterInfo.selectionAnimation != null ? characterInfo.selectionAnimation : characterInfo.moves[0].basicMoves.idle.animMap[0].clip; if (characterInfo.characterPrefabStorage == StorageMode.Prefab) { this.gameObjectPlayer2 = GameObject.Instantiate(characterInfo.characterPrefab); } else { this.gameObjectPlayer2 = GameObject.Instantiate(Resources.Load <GameObject>(characterInfo.prefabResourcePath)); } //this.gameObjectPlayer2 = GameObject.Instantiate(characterInfo.characterPrefab); this.gameObjectPlayer2.transform.position = this.positionPlayer2; this.gameObjectPlayer2.transform.localRotation = Quaternion.Euler(0f, -90f, 0f); this.gameObjectPlayer2.transform.SetParent(this.transform, true); HitBoxesScript hitBoxes = this.gameObjectPlayer2.GetComponent <HitBoxesScript>(); if (hitBoxes != null) { foreach (HitBox hitBox in hitBoxes.hitBoxes) { if (hitBox != null && hitBox.bodyPart != BodyPart.none && hitBox.position != null) { hitBox.position.gameObject.SetActive(hitBox.defaultVisibility); } } } if (characterInfo.animationType == AnimationType.Legacy) { Animation animation = this.gameObjectPlayer2.GetComponent <Animation>(); if (animation == null) { animation = this.gameObjectPlayer2.AddComponent <Animation>(); } this.gameObjectPlayer2.transform.localScale = new Vector3( -this.gameObjectPlayer2.transform.localScale.x, this.gameObjectPlayer2.transform.localScale.y, this.gameObjectPlayer2.transform.localScale.z ); animation.AddClip(clip, "Idle"); animation.wrapMode = WrapMode.Loop; animation.Play("Idle"); } else { Animator animator = this.gameObjectPlayer2.GetComponent <Animator>(); if (animator == null) { animator = this.gameObjectPlayer2.AddComponent <Animator>(); } // Mecanim, mirror via Animator... AnimatorOverrideController overrideController = new AnimatorOverrideController(); overrideController.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("MC_Controller"); overrideController["State3"] = clip; animator.avatar = characterInfo.avatar; animator.applyRootMotion = characterInfo.applyRootMotion; animator.runtimeAnimatorController = overrideController; animator.Play("State3"); } } } } // Deal with alternative colors if both players have selected the same character /*if (this.gameObjectPlayer2 != null && this.displayMode == DisplayMode.CharacterGameObject){ * UFE3D.CharacterInfo p2CharacterInfo = UFE.config.characters[this.p2HoverIndex]; * if (p2CharacterInfo.enableAlternativeColor && this.p1HoverIndex == this.p2HoverIndex){ * foreach(Renderer renderer in this.gameObjectPlayer2.GetComponentsInChildren<Renderer>()){ * renderer.material.color = p2CharacterInfo.alternativeColor; * } * }else{ * Renderer[] originalRenderers = p2CharacterInfo.characterPrefab.GetComponentsInChildren<Renderer>(true); * Renderer[] instanceRenderers = this.gameObjectPlayer2.GetComponentsInChildren<Renderer>(true); * * for (int i = 0; i < originalRenderers.Length && i < instanceRenderers.Length; ++i){ * instanceRenderers[i].material.color = originalRenderers[i].sharedMaterial.color; * } * } * }*/ // Then, update the cursor position if (this.hudPlayer1 != null) { RectTransform rt = this.hudPlayer1.transform as RectTransform; if (rt != null) { rt.anchoredPosition = this.characters[this.p1HoverIndex].rectTransform.anchoredPosition; } else { this.hudPlayer1.transform.position = this.characters[this.p1HoverIndex].transform.position; } } if (this.hudPlayer2 != null) { RectTransform rt = this.hudPlayer2.transform as RectTransform; if (rt != null) { rt.anchoredPosition = this.characters[this.p2HoverIndex].rectTransform.anchoredPosition; } else { this.hudPlayer2.transform.position = this.characters[this.p2HoverIndex].transform.position; } } if (this.hudBothPlayers != null) { RectTransform rt = this.hudBothPlayers.transform as RectTransform; if (rt != null) { rt.anchoredPosition = this.characters[this.p2HoverIndex].rectTransform.anchoredPosition; } else { this.hudBothPlayers.transform.position = this.characters[this.p2HoverIndex].transform.position; } } } this.UpdateHud(); } }
public void Start() { /*Plane groundPlane = (Plane) GameObject.FindObjectOfType(typeof(Plane)); if (groundPlane == null) Debug.LogError("Plane not found. Please add a plane mesh to your stage prefab!");*/ groundLayer = LayerMask.NameToLayer("Ground"); groundMask = 1 << groundLayer; myControlsScript = GetComponent<ControlsScript>(); character = myControlsScript.character; myHitBoxesScript = character.GetComponent<HitBoxesScript>(); myMoveSetScript = character.GetComponent<MoveSetScript>(); appliedGravity = myControlsScript.myInfo.physics.weight * UFE.config.gravity; }
public void OnGUI() { if (characterInfo == null) { GUILayout.BeginHorizontal("GroupBox"); GUILayout.Label("Select a character file or create a new character.", "CN EntryInfo"); GUILayout.EndHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Create new character")) { ScriptableObjectUtility.CreateAsset <CharacterInfo> (); } return; } GUIStyle fontStyle = new GUIStyle(); fontStyle.font = (Font)EditorGUIUtility.Load("EditorFont.TTF"); fontStyle.fontSize = 30; fontStyle.alignment = TextAnchor.UpperCenter; fontStyle.normal.textColor = Color.white; fontStyle.hover.textColor = Color.white; EditorGUILayout.BeginVertical(titleStyle); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("", (characterInfo.characterName == ""? "New Character":characterInfo.characterName), fontStyle, GUILayout.Height(32)); helpButton("character:start"); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); { EditorGUILayout.BeginVertical(rootGroupStyle); { EditorGUILayout.BeginHorizontal(); { //Rect rect = GUILayoutUtility.GetRect(120, 120); //characterInfo.profilePicture = (Texture2D) EditorGUI.ObjectField(rect, characterInfo.profilePicture, typeof(Texture2D), false); characterInfo.profilePictureSmall = (Texture2D)EditorGUILayout.ObjectField(characterInfo.profilePictureSmall, typeof(Texture2D), false, GUILayout.Width(100), GUILayout.Height(122)); EditorGUILayout.BeginVertical(); { EditorGUIUtility.labelWidth = 90; characterInfo.characterName = EditorGUILayout.TextField("Name:", characterInfo.characterName); characterInfo.age = EditorGUILayout.IntField("Age:", characterInfo.age); bloodTypeChoice = EditorGUILayout.Popup("Blood Type:", bloodTypeChoice, bloodTypeChoices); characterInfo.bloodType = bloodTypeChoices[bloodTypeChoice]; characterInfo.gender = (Gender)EditorGUILayout.EnumPopup("Gender:", characterInfo.gender); characterInfo.height = EditorGUILayout.FloatField("Height:", characterInfo.height); characterInfo.lifePoints = EditorGUILayout.IntField("Life Points:", characterInfo.lifePoints); characterInfo.maxGaugePoints = EditorGUILayout.IntField("Max Gauge:", characterInfo.maxGaugePoints); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); EditorGUIUtility.labelWidth = 180; EditorGUILayout.LabelField("Portrail Big:"); characterInfo.profilePictureBig = (Texture2D)EditorGUILayout.ObjectField(characterInfo.profilePictureBig, typeof(Texture2D), false); EditorGUILayout.Space(); characterInfo.alternativeColor = EditorGUILayout.ColorField("Alternative Color:", characterInfo.alternativeColor); characterInfo.deathSound = (AudioClip)EditorGUILayout.ObjectField("Death Sound:", characterInfo.deathSound, typeof(UnityEngine.AudioClip), false); EditorGUIUtility.labelWidth = 150; EditorGUILayout.Space(); GUILayout.Label("Description:"); Rect rect = GUILayoutUtility.GetRect(50, 70); EditorStyles.textField.wordWrap = true; characterInfo.characterDescription = EditorGUI.TextArea(rect, characterInfo.characterDescription); //characterInfo.characterDescription = EditorGUILayout.TextArea(characterInfo.characterDescription, GUILayout.Height(50), GUILayout.Width(Screen.width - 64)); //EditorGUIUtility.labelWidth = 180; EditorGUILayout.Space(); } EditorGUILayout.EndVertical(); // Hit Boxes EditorGUILayout.BeginVertical(rootGroupStyle); { EditorGUILayout.BeginHorizontal(); { hitBoxesOption = EditorGUILayout.Foldout(hitBoxesOption, "Hit Box Setup", foldStyle); helpButton("character:hitbox"); } EditorGUILayout.EndHorizontal(); if (hitBoxesOption) { EditorGUILayout.BeginVertical(subGroupStyle); { EditorGUI.indentLevel += 1; characterInfo.characterPrefab = (GameObject)EditorGUILayout.ObjectField("Character Prefab:", characterInfo.characterPrefab, typeof(UnityEngine.GameObject), true); if (characterInfo.characterPrefab != null) { if (PrefabUtility.GetPrefabType(characterInfo.characterPrefab) != PrefabType.Prefab) { characterWarning = true; errorMsg = "This character is not a prefab."; characterInfo.characterPrefab = null; ClosePreview(); } else if (characterInfo.characterPrefab.GetComponent <HitBoxesScript>() == null) { characterWarning = true; errorMsg = "This character doesn't have hitboxes!\n Please add the HitboxScript and try again."; characterInfo.characterPrefab = null; ClosePreview(); } else if (character != null && EditorApplication.isPlayingOrWillChangePlaymode) { characterWarning = true; errorMsg = "You can't change this field while in play mode."; ClosePreview(); } else { characterWarning = false; if (character != null && characterInfo.characterPrefab.name != character.name) { ClosePreview(); } } } if (characterWarning) { GUILayout.BeginHorizontal("GroupBox"); GUILayout.Label(errorMsg, "CN EntryWarn"); GUILayout.EndHorizontal(); } if (characterInfo.characterPrefab != null) { if (!characterPreviewToggle) { if (StyledButton("Open Character")) { EditorWindow.FocusWindowIfItsOpen <SceneView>(); PreviewCharacter(); } } else { if (StyledButton("Close Character")) { ClosePreview(); } } if (character != null) { EditorGUILayout.BeginVertical(subGroupStyle); { EditorGUILayout.Space(); transformToggle = EditorGUILayout.Foldout(transformToggle, "Transform", EditorStyles.foldout); if (transformToggle) { EditorGUILayout.BeginVertical(subGroupStyle); { EditorGUI.indentLevel += 1; character.transform.position = EditorGUILayout.Vector3Field("Position", character.transform.position); character.transform.rotation = Quaternion.Euler(EditorGUILayout.Vector3Field("Rotation", character.transform.rotation.eulerAngles)); character.transform.localScale = EditorGUILayout.Vector3Field("Scale", character.transform.localScale); EditorGUI.indentLevel -= 1; } EditorGUILayout.EndVertical(); } EditorGUILayout.Space(); hitBoxesToggle = EditorGUILayout.Foldout(hitBoxesToggle, "Hit Boxes", EditorStyles.foldout); if (hitBoxesToggle) { EditorGUILayout.BeginVertical(subGroupStyle); { HitBoxesScript hitBoxesScript = character.GetComponent <HitBoxesScript>(); for (int i = 0; i < hitBoxesScript.hitBoxes.Length; i++) { EditorGUILayout.Space(); EditorGUILayout.BeginVertical(subArrayElementStyle); { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); { hitBoxesScript.hitBoxes[i].bodyPart = (BodyPart)EditorGUILayout.EnumPopup("Body Part:", hitBoxesScript.hitBoxes[i].bodyPart, enumStyle); if (GUILayout.Button("", removeButtonStyle)) { hitBoxesScript.hitBoxes = RemoveElement <HitBox>(hitBoxesScript.hitBoxes, hitBoxesScript.hitBoxes[i]); return; } } EditorGUILayout.EndHorizontal(); hitBoxesScript.hitBoxes[i].collisionType = (CollisionType)EditorGUILayout.EnumPopup("Collision Type:", hitBoxesScript.hitBoxes[i].collisionType, enumStyle); hitBoxesScript.hitBoxes[i].type = (HitBoxType)EditorGUILayout.EnumPopup("Hit Box Type:", hitBoxesScript.hitBoxes[i].type, enumStyle); hitBoxesScript.hitBoxes[i].offSet = EditorGUILayout.Vector2Field("Off Set:", hitBoxesScript.hitBoxes[i].offSet); hitBoxesScript.hitBoxes[i].radius = EditorGUILayout.Slider("Radius:", hitBoxesScript.hitBoxes[i].radius, .1f, 5); hitBoxesScript.hitBoxes[i].position = (Transform)EditorGUILayout.ObjectField("Link:", hitBoxesScript.hitBoxes[i].position, typeof(UnityEngine.Transform), true); EditorGUILayout.Space(); } EditorGUILayout.EndVertical(); } if (StyledButton("New Hit Box")) { hitBoxesScript.hitBoxes = AddElement <HitBox>(hitBoxesScript.hitBoxes, new HitBox()); } } EditorGUILayout.EndVertical(); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); { if (StyledButton("Reset Scene View")) { EditorCamera.SetPosition(Vector3.up * 3.5f); EditorCamera.SetRotation(Quaternion.identity); EditorCamera.SetOrthographic(true); EditorCamera.SetSize(5); } if (StyledButton("Apply Changes")) { PrefabUtility.ReplacePrefab(character, PrefabUtility.GetPrefabParent(character), ReplacePrefabOptions.ConnectToPrefab); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); } EditorGUILayout.EndVertical(); } } EditorGUI.indentLevel -= 1; } EditorGUILayout.EndVertical(); } else { ClosePreview(); } } EditorGUILayout.EndVertical(); // Physics EditorGUILayout.BeginVertical(rootGroupStyle); { EditorGUILayout.BeginHorizontal(); { physicsOption = EditorGUILayout.Foldout(physicsOption, "Physics", foldStyle); helpButton("character:physics"); } EditorGUILayout.EndHorizontal(); if (physicsOption) { EditorGUILayout.BeginVertical(subGroupStyle); { EditorGUILayout.Space(); EditorGUI.indentLevel += 1; characterInfo.physics.moveForwardSpeed = EditorGUILayout.FloatField("Move Forward Speed:", characterInfo.physics.moveForwardSpeed); characterInfo.physics.moveBackSpeed = EditorGUILayout.FloatField("Move Back Speed:", characterInfo.physics.moveBackSpeed); characterInfo.physics.highMovingFriction = EditorGUILayout.Toggle("High Moving Friction", characterInfo.physics.highMovingFriction); characterInfo.physics.friction = EditorGUILayout.FloatField("Friction:", characterInfo.physics.friction); characterInfo.physics.jumpForce = EditorGUILayout.FloatField("Jump Force:", characterInfo.physics.jumpForce); characterInfo.physics.jumpDistance = EditorGUILayout.FloatField("Jump Distance:", characterInfo.physics.jumpDistance); characterInfo.physics.multiJumps = EditorGUILayout.IntField("Air Jumps:", characterInfo.physics.multiJumps); characterInfo.physics.weight = EditorGUILayout.FloatField("Character's Weight:", characterInfo.physics.weight); characterInfo.physics.cumulativeForce = EditorGUILayout.Toggle("Cumulative Force", characterInfo.physics.cumulativeForce); EditorGUILayout.Space(); EditorGUI.indentLevel -= 1; } EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); // Move Sets EditorGUILayout.BeginVertical(rootGroupStyle); { EditorGUILayout.BeginHorizontal(); { moveSetOption = EditorGUILayout.Foldout(moveSetOption, "Move Sets (" + characterInfo.moves.Length + ")", foldStyle); helpButton("character:movesets"); } EditorGUILayout.EndHorizontal(); if (moveSetOption) { EditorGUILayout.BeginVertical(subGroupStyle); { EditorGUILayout.Space(); EditorGUI.indentLevel += 1; // content characterInfo.executionTiming = EditorGUILayout.FloatField("Execution Timing:", characterInfo.executionTiming); characterInfo.chargeTiming = EditorGUILayout.FloatField("Charge Timing:", characterInfo.chargeTiming); characterInfo.possibleAirMoves = EditorGUILayout.IntField("Possible Air Moves:", characterInfo.possibleAirMoves); characterInfo.interpolationSpeed = EditorGUILayout.FloatField("Interpolation Speed:", characterInfo.interpolationSpeed); EditorGUI.indentLevel += 1; for (int i = 0; i < characterInfo.moves.Length; i++) { EditorGUILayout.Space(); EditorGUILayout.BeginVertical(arrayElementStyle); { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); { characterInfo.moves[i].combatStance = (CombatStances)EditorGUILayout.EnumPopup("Combat Stance:", characterInfo.moves[i].combatStance, enumStyle); if (GUILayout.Button("", removeButtonStyle)) { characterInfo.moves = RemoveElement <MoveSetData>(characterInfo.moves, characterInfo.moves[i]); return; } } EditorGUILayout.EndHorizontal(); characterInfo.moves[i].cinematicIntro = (MoveInfo)EditorGUILayout.ObjectField("Cinematic Intro:", characterInfo.moves[i].cinematicIntro, typeof(MoveInfo), false); characterInfo.moves[i].cinematicOutro = (MoveInfo)EditorGUILayout.ObjectField("Cinematic Outro:", characterInfo.moves[i].cinematicOutro, typeof(MoveInfo), false); EditorGUILayout.Space(); characterInfo.moves[i].basicMovesToggle = EditorGUILayout.Foldout(characterInfo.moves[i].basicMovesToggle, "Basic Moves", foldStyle); if (characterInfo.moves[i].basicMovesToggle) { EditorGUILayout.BeginVertical(subGroupStyle); { EditorGUI.indentLevel += 1; EditorGUILayout.Space(); basicMoveBlock("Idle", characterInfo.moves[i].basicMoves.idle, false, true); basicMoveBlock("Move Forward", characterInfo.moves[i].basicMoves.moveForward, false, true); basicMoveBlock("Move Back", characterInfo.moves[i].basicMoves.moveBack, false, true); basicMoveBlock("Jumping", characterInfo.moves[i].basicMoves.jumping, true, true); basicMoveBlock("Falling", characterInfo.moves[i].basicMoves.falling, true, true); basicMoveBlock("Landing", characterInfo.moves[i].basicMoves.landing, true, true); basicMoveBlock("Crouching", characterInfo.moves[i].basicMoves.crouching, false, true); basicMoveBlock("Blocking Low Pose", characterInfo.moves[i].basicMoves.blockingLowPose, false, true); basicMoveBlock("Blocking Low Hit", characterInfo.moves[i].basicMoves.blockingLowHit, true, true); basicMoveBlock("Blocking High Pose", characterInfo.moves[i].basicMoves.blockingHighPose, false, true); basicMoveBlock("Blocking High Hit", characterInfo.moves[i].basicMoves.blockingHighHit, true, true); basicMoveBlock("Blocking Air Pose", characterInfo.moves[i].basicMoves.blockingAirPose, false, true); basicMoveBlock("Blocking Air Hit", characterInfo.moves[i].basicMoves.blockingAirHit, true, true); basicMoveBlock("Parry Crouching", characterInfo.moves[i].basicMoves.parryCrouching, true, true); basicMoveBlock("Parry High", characterInfo.moves[i].basicMoves.parryHigh, true, true); basicMoveBlock("Parry Air", characterInfo.moves[i].basicMoves.parryAir, true, true); basicMoveBlock("Get Hit Crouching", characterInfo.moves[i].basicMoves.getHitCrouching, true, true); basicMoveBlock("Get Hit High", characterInfo.moves[i].basicMoves.getHitHigh, true, true); basicMoveBlock("Get Hit Air", characterInfo.moves[i].basicMoves.getHitAir, true, true); basicMoveBlock("Fall Down", characterInfo.moves[i].basicMoves.fallDown, true, true); basicMoveBlock("Get Up", characterInfo.moves[i].basicMoves.getUp, true, true); basicMoveBlock("Bounce", characterInfo.moves[i].basicMoves.bounce, true, true); basicMoveBlock("Falling From Bounce", characterInfo.moves[i].basicMoves.fallingFromBounce, true, true); EditorGUI.indentLevel -= 1; EditorGUILayout.Space(); } EditorGUILayout.EndVertical(); } characterInfo.moves[i].attackMovesToggle = EditorGUILayout.Foldout(characterInfo.moves[i].attackMovesToggle, "Attack & Special Moves (" + characterInfo.moves[i].attackMoves.Length + ")", foldStyle); if (characterInfo.moves[i].attackMovesToggle) { EditorGUILayout.BeginVertical(subGroupStyle); { EditorGUILayout.Space(); EditorGUI.indentLevel += 1; for (int y = 0; y < characterInfo.moves[i].attackMoves.Length; y++) { EditorGUILayout.Space(); EditorGUILayout.BeginVertical(subArrayElementStyle); { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); { characterInfo.moves[i].attackMoves[y] = (MoveInfo)EditorGUILayout.ObjectField("Move File:", characterInfo.moves[i].attackMoves[y], typeof(MoveInfo), false); if (GUILayout.Button("", removeButtonStyle)) { characterInfo.moves[i].attackMoves = RemoveElement <MoveInfo>(characterInfo.moves[i].attackMoves, characterInfo.moves[i].attackMoves[y]); return; } } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Open in the Move Editor")) { MoveEditorWindow.sentMoveInfo = characterInfo.moves[i].attackMoves[y]; MoveEditorWindow.Init(); } } EditorGUILayout.EndVertical(); } EditorGUILayout.Space(); if (StyledButton("New Move")) { characterInfo.moves[i].attackMoves = AddElement <MoveInfo>(characterInfo.moves[i].attackMoves, null); } EditorGUILayout.Space(); EditorGUI.indentLevel -= 1; } EditorGUILayout.EndVertical(); } EditorGUILayout.Space(); } EditorGUILayout.EndVertical(); } EditorGUILayout.Space(); if (StyledButton("New Move Set")) { characterInfo.moves = AddElement <MoveSetData>(characterInfo.moves, new MoveSetData()); } EditorGUILayout.Space(); EditorGUI.indentLevel -= 1; } EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); if (GUI.changed) { Undo.RecordObject(characterInfo, "Character Editor Modify"); EditorUtility.SetDirty(characterInfo); } }