public override void AssignConstantIDs(bool saveScriptsToo, bool fromAssetFile) { Shapeable obToUpdate = shapeObject; if (isPlayer && (KickStarter.settingsManager == null || KickStarter.settingsManager.playerSwitching == PlayerSwitching.DoNotAllow)) { if (!fromAssetFile) { Player charToUpdate = FindObjectOfType <Player> (); if (charToUpdate != null) { obToUpdate = charToUpdate.GetShapeable(); } } if (obToUpdate == null && AdvGame.GetReferences().settingsManager != null) { Player player = AdvGame.GetReferences().settingsManager.GetDefaultPlayer(); obToUpdate = player.GetShapeable(); } } if (saveScriptsToo) { AddSaveScript <RememberShapeable> (obToUpdate); } AssignConstantID <Shapeable> (obToUpdate, constantID, parameterID); }
public override string SaveData() { ShapeableData shapeableData = new ShapeableData(); shapeableData.objectID = constantID; shapeableData.savePrevented = savePrevented; Shapeable shapeable = GetComponent <Shapeable>(); if (shapeable != null) { List <int> activeKeyIDs = new List <int>(); List <float> values = new List <float>(); foreach (ShapeGroup shapeGroup in shapeable.shapeGroups) { activeKeyIDs.Add(shapeGroup.GetActiveKeyID()); values.Add(shapeGroup.GetActiveKeyValue()); } shapeableData._activeKeyIDs = ArrayToString <int> (activeKeyIDs.ToArray()); shapeableData._values = ArrayToString <float> (values.ToArray()); } return(Serializer.SaveScriptData <ShapeableData> (shapeableData)); }
/** * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary> * <param name = "stringData">The data, serialised as a string</param> */ public override void LoadData(string stringData) { ShapeableData data = Serializer.LoadScriptData <ShapeableData> (stringData); if (data == null) { return; } if (GetComponent <Shapeable>()) { Shapeable shapeable = GetComponent <Shapeable>(); int[] activeKeyIDs = StringToIntArray(data._activeKeyIDs); float[] values = StringToFloatArray(data._values); for (int i = 0; i < activeKeyIDs.Length; i++) { if (values.Length > i) { shapeable.shapeGroups[i].SetActive(activeKeyIDs[i], values[i], 0f, MoveMethod.Linear, null); } } } }
public override void OnInspectorGUI() { Shapeable _target = (Shapeable)target; _target.shapeGroups = AllGroupsGUI(_target.shapeGroups); if (selectedGroup != null) { List <string> blendShapeNames = new List <string>(); if (_target.GetComponent <SkinnedMeshRenderer>() && _target.GetComponent <SkinnedMeshRenderer>().sharedMesh) { for (int i = 0; i < _target.GetComponent <SkinnedMeshRenderer>().sharedMesh.blendShapeCount; i++) { blendShapeNames.Add(_target.GetComponent <SkinnedMeshRenderer>().sharedMesh.GetBlendShapeName(i)); } } else { EditorGUILayout.HelpBox("This component should be attached to a Skinned Mesh Renderer.", MessageType.Warning); } selectedGroup = GroupGUI(selectedGroup, blendShapeNames.ToArray()); } if (GUI.changed) { EditorUtility.SetDirty(_target); } }
public override void AssignValues(List <ActionParameter> parameters) { if (animEngine == null) { ResetAnimationEngine(); } if (animEngine != null) { animEngine.ActionAnimAssignValues(this, parameters); } parameterName = AssignString(parameters, parameterNameID, parameterName); clip2D = AssignString(parameters, clip2DParameterID, clip2D); if (method == AnimMethod.BlendShape && isPlayer) { if (KickStarter.player && KickStarter.player.GetComponent <Shapeable>()) { runtimeShapeObject = KickStarter.player.GetComponent <Shapeable>(); } else { runtimeShapeObject = null; ACDebug.LogWarning("Cannot BlendShape Player since cannot find Shapeable script on Player."); } } }
public override void AssignValues(List <ActionParameter> parameters) { runtimeShapeObject = AssignFile <Shapeable> (parameters, parameterID, constantID, shapeObject); if (isPlayer && KickStarter.player) { runtimeShapeObject = KickStarter.player.GetShapeable(); } }
public override void AssignValues(List <ActionParameter> parameters) { runtimeShapeObject = AssignFile <Shapeable> (parameters, parameterID, constantID, shapeObject); if (isPlayer) { Player player = AssignPlayer(playerID, parameters, playerParameterID); runtimeShapeObject = (player != null) ? player.GetShapeable() : null; } }
/** * <summary>Creates a new instance of the 'Object: Blend shape' Action, set to disable all keys on a Shapeable</summary> * <param name = "shapeable">The Shapeable to manipulate</param> * <param name = "groupID">The ID of the group to affect</param> * <param name = "transitionTime">The time, in seconds, to take</param> * <param name = "waitUntilFinish">If True, then the Action will wait until the transition is complete</param> * <returns>The generated Action</returns> */ public static ActionBlendShape CreateNew_DisableAllKeys(Shapeable shapeable, int groupID, float transitionTime = 0f, MoveMethod moveMethod = MoveMethod.Linear, AnimationCurve timeCurve = null) { ActionBlendShape newAction = (ActionBlendShape)CreateInstance <ActionBlendShape>(); newAction.disableAllKeys = true; newAction.shapeObject = shapeable; newAction.shapeGroupID = groupID; newAction.fadeTime = transitionTime; newAction.moveMethod = moveMethod; newAction.timeCurve = timeCurve; return(newAction); }
/** * <summary>Creates a new instance of the 'Object: Animate' Action, set to control Blendshapes</summary> * <param name = "shapeable">The Shapeable to manipulate</param> * <param name = "shapeKey">The ID of the key to affect</param> * <param name = "shape">The shape key's new value</param> * <param name = "transitionTime">The time, in seconds, to take when transitioning</param> * <param name = "waitUntilFinish">If True, then the Action will wait until the transition is complete</param> * <returns>The generated Action</returns> */ public static ActionAnim CreateNew_BlendShape(Shapeable shapeable, int shapeKey, float shapeValue, float transitionTime = 1f, bool waitUntilFinish = false) { ActionAnim newAction = (ActionAnim)CreateInstance <ActionAnim>(); newAction.animationEngine = AnimationEngine.Mecanim; newAction.methodMecanim = AnimMethodMecanim.BlendShape; newAction.shapeObject = shapeable; newAction.shapeKey = shapeKey; newAction.shapeValue = shapeValue; newAction.fadeTime = transitionTime; newAction.willWait = waitUntilFinish; return(newAction); }
public override void OnInspectorGUI() { Shapeable _target = (Shapeable)target; _target.shapeGroups = AllGroupsGUI(_target.shapeGroups); if (selectedGroup != null) { selectedGroup = GroupGUI(selectedGroup); } if (GUI.changed) { EditorUtility.SetDirty(_target); } }
public override void AssignValues(List <ActionParameter> parameters) { runtimeShapeObject = AssignFile <Shapeable> (parameters, parameterID, constantID, shapeObject); if (isPlayer) { if (KickStarter.player && KickStarter.player.GetShapeable()) { runtimeShapeObject = KickStarter.player.GetShapeable(); } else { runtimeShapeObject = null; ACDebug.LogWarning("Cannot BlendShape Player since cannot find Shapeable script on Player."); } } }
public override void AssignValues(List<ActionParameter> parameters) { shapeObject = AssignFile <Shapeable> (parameters, parameterID, constantID, shapeObject); if (isPlayer) { if (KickStarter.player && KickStarter.player.GetShapeable ()) { shapeObject = KickStarter.player.GetShapeable (); } else { shapeObject = null; ACDebug.LogWarning ("Cannot BlendShape Player since cannot find Shapeable script on Player."); } } }
public override void AssignValues(List <ActionParameter> parameters) { if (animEngine == null) { ResetAnimationEngine(); } if (animEngine != null) { animEngine.ActionAnimAssignValues(this, parameters); } parameterName = AssignString(parameters, parameterNameID, parameterName); clip2D = AssignString(parameters, clip2DParameterID, clip2D); if (method == AnimMethod.BlendShape && isPlayer && KickStarter.player) { runtimeShapeObject = KickStarter.player.GetComponent <Shapeable>(); } }
override public void AssignConstantIDs(bool saveScriptsToo, bool fromAssetFile) { if (saveScriptsToo) { if (method == AnimMethod.BlendShape) { if (isPlayer) { if (!fromAssetFile && GameObject.FindObjectOfType <Player>() != null) { Player player = GameObject.FindObjectOfType <Player>(); shapeObject = player.GetComponent <Shapeable>(); } if (shapeObject == null && AdvGame.GetReferences().settingsManager) { Player player = AdvGame.GetReferences().settingsManager.GetDefaultPlayer(); if (player != null) { shapeObject = player.GetComponent <Shapeable>(); } } } if (shapeObject != null) { AddSaveScript <RememberShapeable> (shapeObject); } } ResetAnimationEngine(); if (animEngine != null && animator != null && animEngine.RequiresRememberAnimator(this)) { animEngine.AddSaveScript(this, animator.gameObject); } } }
override public void AssignConstantIDs(bool saveScriptsToo, bool fromAssetFile) { Shapeable obToUpdate = shapeObject; if (isPlayer) { if (!fromAssetFile && GameObject.FindObjectOfType <Player>() != null) { obToUpdate = GameObject.FindObjectOfType <Player>().GetShapeable(); } if (obToUpdate == null && AdvGame.GetReferences().settingsManager != null) { Player player = AdvGame.GetReferences().settingsManager.GetDefaultPlayer(); obToUpdate = player.GetShapeable(); } } if (saveScriptsToo) { AddSaveScript <RememberShapeable> (obToUpdate); } AssignConstantID <Shapeable> (obToUpdate, constantID, parameterID); }
protected void _Awake() { if (GetComponent <CharacterController>()) { _characterController = GetComponent <CharacterController>(); wallRayOrigin = _characterController.center; wallRayForward = _characterController.radius; } else if (GetComponent <CapsuleCollider>()) { CapsuleCollider capsuleCollider = GetComponent <CapsuleCollider>(); wallRayOrigin = capsuleCollider.center; wallRayForward = capsuleCollider.radius; } else if (GetComponent <CircleCollider2D>()) { CircleCollider2D circleCollider = GetComponent <CircleCollider2D>(); #if !UNITY_5 wallRayOrigin = circleCollider.center; #else wallRayOrigin = circleCollider.offset; #endif wallRayForward = circleCollider.radius; } else if (GetComponent <BoxCollider2D>()) { BoxCollider2D boxCollider = GetComponent <BoxCollider2D>(); wallRayOrigin = boxCollider.bounds.center; wallRayForward = boxCollider.bounds.size.x / 2f; } if (GetComponentInChildren <FollowSortingMap>()) { transform.localScale = Vector3.one; } originalScale = transform.localScale; charState = CharState.Idle; shapeable = GetShapeable (); if (GetComponent <LipSyncTexture>()) { lipSyncTexture = GetComponent <LipSyncTexture>(); } ResetAnimationEngine (); ResetBaseClips (); _animator = GetAnimator (); _animation = GetAnimation (); SetAntiGlideState (); if (spriteChild && spriteChild.gameObject.GetComponent <SpriteRenderer>()) { _spriteRenderer = spriteChild.gameObject.GetComponent <SpriteRenderer>(); if (spriteChild.localPosition.magnitude > 0f) { if (!(gameObject.name == "Bird" && spriteChild.gameObject.name == "Bird_Sprite")) { // You found the dirtest hack in AC! ACDebug.LogWarning ("The sprite child of '" + gameObject.name + "' is not positioned at (0,0,0) - is this correct?"); } } } if (speechAudioSource == null && GetComponent <AudioSource>()) { speechAudioSource = GetComponent <AudioSource>(); } if (soundChild && soundChild.gameObject.GetComponent <AudioSource>()) { audioSource = soundChild.gameObject.GetComponent <AudioSource>(); } if (GetComponent <Rigidbody>()) { _rigidbody = GetComponent <Rigidbody>(); } else if (GetComponent <Rigidbody2D>()) { _rigidbody2D = GetComponent <Rigidbody2D>(); } PhysicsUpdate (); if (GetComponent <Collider>()) { _collider = GetComponent <Collider>(); } AdvGame.AssignMixerGroup (speechAudioSource, SoundType.Speech, true); AdvGame.AssignMixerGroup (audioSource, SoundType.SFX); }
override public void ShowGUI(List <ActionParameter> parameters) { isPlayer = EditorGUILayout.Toggle("Is player?", isPlayer); if (!isPlayer) { parameterID = ChooseParameterGUI("Object:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; shapeObject = null; } else { shapeObject = (Shapeable)EditorGUILayout.ObjectField("Object:", shapeObject, typeof(Shapeable), true); constantID = FieldToID <Shapeable> (shapeObject, constantID); shapeObject = IDToField <Shapeable> (shapeObject, constantID, false); } } else { Player _player = null; if (Application.isPlaying) { _player = KickStarter.player; } else { _player = AdvGame.GetReferences().settingsManager.GetDefaultPlayer(); } if (_player != null && _player.GetShapeable()) { shapeObject = _player.GetShapeable(); } else { shapeObject = null; EditorGUILayout.HelpBox("Cannot find player with Shapeable script attached", MessageType.Warning); } } if (shapeObject != null && shapeObject.shapeGroups != null) { shapeGroupID = ActionBlendShape.ShapeableGroupGUI("Shape group:", shapeObject.shapeGroups, shapeGroupID); disableAllKeys = EditorGUILayout.Toggle("Disable all keys?", disableAllKeys); if (!disableAllKeys) { ShapeGroup _shapeGroup = shapeObject.GetGroup(shapeGroupID); if (_shapeGroup != null) { if (_shapeGroup.shapeKeys != null && _shapeGroup.shapeKeys.Count > 0) { shapeKeyID = ShapeableKeyGUI(_shapeGroup.shapeKeys, shapeKeyID); } else { EditorGUILayout.HelpBox("No shape keys found.", MessageType.Info); } } shapeValue = EditorGUILayout.Slider("New value:", shapeValue, 0f, 100f); } } else { EditorGUILayout.HelpBox("An object must be assigned before more options can show.", MessageType.Info); } fadeTime = EditorGUILayout.FloatField("Transition time:", fadeTime); if (fadeTime > 0f) { moveMethod = (MoveMethod)EditorGUILayout.EnumPopup("Move method:", moveMethod); if (moveMethod == MoveMethod.CustomCurve) { timeCurve = EditorGUILayout.CurveField("Time curve:", timeCurve); } willWait = EditorGUILayout.Toggle("Wait until finish?", willWait); } AfterRunningOption(); }
protected void _Awake() { if (GetComponent <CharacterController>()) { _characterController = GetComponent <CharacterController>(); wallRayOrigin = _characterController.center; wallRayForward = _characterController.radius; } else if (GetComponent <CapsuleCollider>()) { CapsuleCollider capsuleCollider = GetComponent <CapsuleCollider>(); wallRayOrigin = capsuleCollider.center; wallRayForward = capsuleCollider.radius; } else if (GetComponent <CircleCollider2D>()) { CircleCollider2D circleCollider = GetComponent <CircleCollider2D>(); #if !UNITY_5 wallRayOrigin = circleCollider.center; #else wallRayOrigin = circleCollider.offset; #endif wallRayForward = circleCollider.radius; } else if (GetComponent <BoxCollider2D>()) { BoxCollider2D boxCollider = GetComponent <BoxCollider2D>(); wallRayOrigin = boxCollider.bounds.center; wallRayForward = boxCollider.bounds.size.x / 2f; } if (GetComponentInChildren <FollowSortingMap>()) { transform.localScale = Vector3.one; } originalScale = transform.localScale; charState = CharState.Idle; shapeable = GetShapeable (); if (GetComponent <LipSyncTexture>()) { lipSyncTexture = GetComponent <LipSyncTexture>(); } ResetAnimationEngine (); ResetBaseClips (); _animator = GetAnimator (); _animation = GetAnimation (); SetAntiGlideState (); if (spriteChild && spriteChild.gameObject.GetComponent <SpriteRenderer>()) { _spriteRenderer = spriteChild.gameObject.GetComponent <SpriteRenderer>(); } if (soundChild && soundChild.gameObject.GetComponent <AudioSource>()) { audioSource = soundChild.gameObject.GetComponent <AudioSource>(); } if (GetComponent <Rigidbody>()) { _rigidbody = GetComponent <Rigidbody>(); } else if (GetComponent <Rigidbody2D>()) { _rigidbody2D = GetComponent <Rigidbody2D>(); } if (GetComponent <Collider>()) { _collider = GetComponent <Collider>(); } AdvGame.AssignMixerGroup (GetComponent <AudioSource>(), SoundType.Other, true); AdvGame.AssignMixerGroup (audioSource, SoundType.SFX); }
public override void ShowGUI(List<ActionParameter> parameters) { isPlayer = EditorGUILayout.Toggle ("Is player?", isPlayer); if (!isPlayer) { parameterID = ChooseParameterGUI ("Object:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; shapeObject = null; } else { shapeObject = (Shapeable) EditorGUILayout.ObjectField ("Object:", shapeObject, typeof (Shapeable), true); constantID = FieldToID <Shapeable> (shapeObject, constantID); shapeObject = IDToField <Shapeable> (shapeObject, constantID, false); } } else { Player _player = null; if (Application.isPlaying) { _player = KickStarter.player; } else { _player = AdvGame.GetReferences ().settingsManager.GetDefaultPlayer (); } if (_player != null && _player.GetShapeable ()) { shapeObject = _player.GetShapeable (); } else { shapeObject = null; EditorGUILayout.HelpBox ("Cannot find player with Shapeable script attached", MessageType.Warning); } } if (shapeObject != null && shapeObject.shapeGroups != null) { shapeGroupID = ActionBlendShape.ShapeableGroupGUI ("Shape group:", shapeObject.shapeGroups, shapeGroupID); disableAllKeys = EditorGUILayout.Toggle ("Disable all keys?", disableAllKeys); if (!disableAllKeys) { ShapeGroup _shapeGroup = shapeObject.GetGroup (shapeGroupID); if (_shapeGroup != null) { if (_shapeGroup.shapeKeys != null && _shapeGroup.shapeKeys.Count > 0) { shapeKeyID = ShapeableKeyGUI (_shapeGroup.shapeKeys, shapeKeyID); } else { EditorGUILayout.HelpBox ("No shape keys found.", MessageType.Info); } } shapeValue = EditorGUILayout.Slider ("New value:", shapeValue, 0f, 100f); } } else { EditorGUILayout.HelpBox ("An object must be assigned before more options can show.", MessageType.Info); } fadeTime = EditorGUILayout.FloatField ("Transition time:", fadeTime); if (fadeTime > 0f) { moveMethod = (MoveMethod) EditorGUILayout.EnumPopup ("Move method:", moveMethod); if (moveMethod == MoveMethod.CustomCurve) { timeCurve = EditorGUILayout.CurveField ("Time curve:", timeCurve); } willWait = EditorGUILayout.Toggle ("Wait until finish?", willWait); } AfterRunningOption (); }
public override void AssignValues(List<ActionParameter> parameters) { if (animEngine == null) { ResetAnimationEngine (); } if (animEngine != null) { animEngine.ActionAnimAssignValues (this, parameters); } if (method == AnimMethod.BlendShape && isPlayer) { if (KickStarter.player && KickStarter.player.GetComponent <Shapeable>()) { shapeObject = KickStarter.player.GetComponent <Shapeable>(); } else { shapeObject = null; ACDebug.LogWarning ("Cannot BlendShape Player since cannot find Shapeable script on Player."); } } }
public Shapeable GetShapeable() { Shapeable shapeable = GetComponent <Shapeable> (); if (shapeable == null) { shapeable = GetComponentInChildren <Shapeable>(); } return shapeable; }
protected void _Awake() { if (GetComponent <CharacterController>()) { _characterController = GetComponent <CharacterController>(); wallRayOrigin = _characterController.center; wallRayForward = _characterController.radius; } else if (GetComponent <CapsuleCollider>()) { CapsuleCollider capsuleCollider = GetComponent <CapsuleCollider>(); wallRayOrigin = capsuleCollider.center; wallRayForward = capsuleCollider.radius; } if (GetComponentInChildren <FollowSortingMap>()) { transform.localScale = Vector3.one; } originalScale = transform.localScale; charState = CharState.Idle; shapeable = GetShapeable (); if (GetComponent <LipSyncTexture>()) { lipSyncTexture = GetComponent <LipSyncTexture>(); } ResetAnimationEngine (); ResetBaseClips (); if (spriteChild && spriteChild.GetComponent <Animator>()) { animator = spriteChild.GetComponent <Animator>(); } if (soundChild && soundChild.gameObject.GetComponent <AudioSource>()) { audioSource = soundChild.gameObject.GetComponent <AudioSource>(); } if (GetComponent <Animator>()) { animator = GetComponent <Animator>(); } if (GetComponent <Animation>()) { _animation = GetComponent <Animation>(); } if (GetComponent <Rigidbody>()) { _rigidbody = GetComponent <Rigidbody>(); } else if (GetComponent <Rigidbody2D>()) { _rigidbody2D = GetComponent <Rigidbody2D>(); } if (GetComponent <Collider>()) { _collider = GetComponent <Collider>(); } AdvGame.AssignMixerGroup (GetComponent <AudioSource>(), SoundType.Other, true); AdvGame.AssignMixerGroup (audioSource, SoundType.SFX); }
protected void _Awake () { originalScale = transform.localScale; charState = CharState.Idle; shapeable = GetShapeable (); ResetAnimationEngine (); ResetBaseClips (); GetSettingsManager (); if (spriteChild && spriteChild.GetComponent <Animator>()) { animator = spriteChild.GetComponent <Animator>(); } if (soundChild && soundChild.gameObject.GetComponent <AudioSource>()) { audioSource = soundChild.gameObject.GetComponent <AudioSource>(); } if (GetComponent <Animator>()) { animator = GetComponent <Animator>(); } if (GetComponent <Animation>()) { _animation = GetComponent <Animation>(); } if (GetComponent <Rigidbody>()) { _rigidbody = GetComponent <Rigidbody>(); } else if (GetComponent <Rigidbody2D>()) { _rigidbody2D = GetComponent <Rigidbody2D>(); } if (GetComponent <Collider>()) { _collider = GetComponent <Collider>(); } }