void Awake()
            {
                if (DefaultClient.OptimizeForServer()) {
                    Destroy(GetComponentInChildren<Animator>());
                    return;
                }

                animator = GetComponentInChildren<Animator>() as Animator;
                defaultController = animator.runtimeAnimatorController;
            }
 protected void AnimStart(RuntimeAnimatorController effect, AudioClip se)
 {
     anim.runtimeAnimatorController = effect;
     anim.SetTrigger("Start");
     soundBox.PlayOneShot(se, 1f);
 }
		public override void OnGUI(Rect position, SerializedProperty property, GUIContent label){
			if (warningIcon == null)
			{
				warningIcon = EditorGUIUtility.FindTexture("console.warnicon.sml");
			}
			EditorGUI.BeginProperty (position, label, property);
			var r0 = new Rect (position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight);
			SerializedProperty foldoutProp1 = property.FindPropertyRelative ("defaultAnimationController");
			foldoutProp1.isExpanded = EditorGUI.Foldout (r0, foldoutProp1.isExpanded, "Race Animation Controllers");

			if (foldoutProp1.isExpanded) {
				EditorGUI.indentLevel++;
				var valR = r0;
				valR = new Rect (valR.xMin, valR.yMax + padding, valR.width, EditorGUIUtility.singleLineHeight);
				EditorGUI.PropertyField (valR,property.FindPropertyRelative ("defaultAnimationController"));
				valR = new Rect (valR.xMin, valR.yMax + padding, valR.width, EditorGUIUtility.singleLineHeight);
				SerializedProperty foldoutProp2 = property.FindPropertyRelative ("animators");
				foldoutProp2.isExpanded = EditorGUI.Foldout (valR, foldoutProp2.isExpanded, "Race Animators");
				//we cant delete elements in the loop so ...
				List<int> willDeleteArrayElementAtIndex = new List<int> ();

				if (foldoutProp2.isExpanded) {
					EditorGUI.indentLevel++;
					var thisAnimatorsProp = property.FindPropertyRelative ("animators");
					var numAnimators = thisAnimatorsProp.arraySize;
					var warningStyle = new GUIStyle(EditorStyles.label);
					warningStyle.fixedHeight = warningIcon.height + 4f;
					warningStyle.contentOffset = new Vector2(0, -2f);
					for (int i = 0; i < numAnimators; i++) {
						var thisAnimtorProp = thisAnimatorsProp.GetArrayElementAtIndex (i);
						valR = new Rect (valR.xMin, valR.yMax + padding, valR.width, EditorGUIUtility.singleLineHeight);
						var propsR = valR;
						propsR.width = propsR.width - 20f;
						var rPropR = propsR;
						rPropR.width = rPropR.width / 2;
						var aPropR = rPropR;
						aPropR.x = propsR.x + rPropR.width;
						var rLabelR = rPropR;
						rLabelR.width = (float)(rLabelR.width * 0.3)+(15f * (EditorGUI.indentLevel -1));
						var rFieldR = rPropR;
						rFieldR.x = rFieldR.x + rLabelR.width;
						rFieldR.width = rFieldR.width - rLabelR.width;
						//
						var aLabelR = aPropR;
						aLabelR.width = (float)(aLabelR.width * 0.3);
						var aFieldR = aPropR;
						aFieldR.x = aFieldR.x + aLabelR.width;
						aFieldR.width = aFieldR.width - aLabelR.width;
						var removeR = propsR;
						removeR.x = aFieldR.xMax;
						removeR.width = 20f;

						EditorGUI.LabelField (rLabelR, "Race");
						EditorGUI.indentLevel--;
						EditorGUI.indentLevel--;
						if (thisAnimtorProp.FindPropertyRelative ("raceName").stringValue == "") {
							//draw an object field for RaceData
							EditorGUI.BeginChangeCheck();
							RaceData thisRD = null;
							thisRD = (RaceData)EditorGUI.ObjectField (rFieldR, thisRD, typeof(RaceData),false);
							//if this gets filled set the values
							if(EditorGUI.EndChangeCheck()){
								if (thisRD != null) {
									thisAnimatorsProp.GetArrayElementAtIndex (i).FindPropertyRelative ("raceName").stringValue = thisRD.raceName;
								}
							}
						}
						else
						{
							EditorGUI.BeginDisabledGroup (true);
							EditorGUI.TextField (rFieldR, thisAnimtorProp.FindPropertyRelative ("raceName").stringValue);
							EditorGUI.EndDisabledGroup ();
						}
						EditorGUI.LabelField (aLabelR, "Animator");
						var thisAnimatorName = thisAnimtorProp.FindPropertyRelative("animatorControllerName").stringValue;
						if (thisAnimatorName == "")
						{
							//draw an object field for RunTimeAnimatorController
							EditorGUI.BeginChangeCheck();
							RuntimeAnimatorController thisRC = null;
							thisRC = (RuntimeAnimatorController)EditorGUI.ObjectField (aFieldR, thisRC, typeof(RuntimeAnimatorController), false);
							//if this gets filled set the values
							if(EditorGUI.EndChangeCheck()){
								if (thisRC != null) {
									thisAnimatorsProp.GetArrayElementAtIndex (i).FindPropertyRelative ("animatorControllerName").stringValue = thisRC.name;
								}
							}
						}
						else
						{
							if (DynamicAssetLoader.Instance)
							{
								if (!CheckAnimatorAvailability(thisAnimatorName))
								{
									var warningRect = new Rect((removeR.xMin - 20f), removeR.yMin, 20f, removeR.height);
									aFieldR.xMax = aFieldR.xMax - 20f;
									//if its in an assetbundle we need a different message (i.e "turn on 'Dynamically Add From AssetBundles"') 
									var warningGUIContent = new GUIContent("", thisAnimtorProp.FindPropertyRelative("animatorControllerName").stringValue + " was not Live. If the asset is in an assetBundle check 'Dynamically Add from AssetBundles' below otherwise click this button to add it to the Global Library.");
									warningGUIContent.image = warningIcon;
									if (GUI.Button(warningRect, warningGUIContent, warningStyle))
									{
										var thisAnimator = FindMissingAnimator(thisAnimatorName);
										if (thisAnimator != null)
											UMAAssetIndexer.Instance.EvilAddAsset(thisAnimator.GetType(), thisAnimator);
										else
											UMAAssetIndexerEditor.ShowWindow();
									}
								}
							}
							EditorGUI.BeginDisabledGroup(true);
							EditorGUI.TextField(aFieldR, thisAnimtorProp.FindPropertyRelative("animatorControllerName").stringValue);
							EditorGUI.EndDisabledGroup();
						}
						if(GUI.Button(removeR,"X")){
							willDeleteArrayElementAtIndex.Add(i);
						}
						EditorGUI.indentLevel++;
						EditorGUI.indentLevel++;
					}
					if (willDeleteArrayElementAtIndex.Count > 0) {
						foreach (int i in willDeleteArrayElementAtIndex) {
							thisAnimatorsProp.DeleteArrayElementAtIndex (i);
						}
					}
					thisAnimatorsProp.serializedObject.ApplyModifiedProperties();
					valR = new Rect (valR.xMin, valR.yMax + padding, valR.width, EditorGUIUtility.singleLineHeight);
					var butValR = valR;
					//GUI doesn't know EditorGUI.indentLevel
					butValR.xMin = valR.xMin + (15 * EditorGUI.indentLevel);
					if(GUI.Button(butValR,"Add Race Animator")){
						//add a new element to the list
						thisAnimatorsProp.InsertArrayElementAtIndex(numAnimators);
						thisAnimatorsProp.serializedObject.ApplyModifiedProperties();
						//make sure its blank
						thisAnimatorsProp.GetArrayElementAtIndex(numAnimators).FindPropertyRelative("raceName").stringValue = "";
						thisAnimatorsProp.GetArrayElementAtIndex(numAnimators).FindPropertyRelative("animatorControllerName").stringValue = "";
						thisAnimatorsProp.GetArrayElementAtIndex(numAnimators).FindPropertyRelative("animatorController").objectReferenceValue = null;
						thisAnimatorsProp.serializedObject.ApplyModifiedProperties();
					}
					EditorGUI.indentLevel--;
				}
				valR = new Rect (valR.xMin, valR.yMax + padding, valR.width, EditorGUIUtility.singleLineHeight);
				var dynamicallyAddFromResources = property.FindPropertyRelative ("dynamicallyAddFromResources").boolValue;
				EditorGUI.BeginChangeCheck();
				dynamicallyAddFromResources = EditorGUI.ToggleLeft(valR,"Dynamically Add from Global Library", dynamicallyAddFromResources);
				if(EditorGUI.EndChangeCheck()){
					property.FindPropertyRelative ("dynamicallyAddFromResources").boolValue = dynamicallyAddFromResources;
					property.serializedObject.ApplyModifiedProperties ();
				}
				valR = new Rect (valR.xMin, valR.yMax + padding, valR.width, EditorGUIUtility.singleLineHeight);
				EditorGUI.PropertyField (valR,property.FindPropertyRelative ("resourcesFolderPath"), new GUIContent("Global Library Folder Filter"));
				valR = new Rect (valR.xMin, valR.yMax + padding, valR.width, EditorGUIUtility.singleLineHeight);
				var dynamicallyAddFromAssetBundles = property.FindPropertyRelative ("dynamicallyAddFromAssetBundles").boolValue;
				EditorGUI.BeginChangeCheck();
				dynamicallyAddFromAssetBundles = EditorGUI.ToggleLeft(valR,"Dynamically Add from Asset Bundles", dynamicallyAddFromAssetBundles);
				if(EditorGUI.EndChangeCheck()){
					property.FindPropertyRelative ("dynamicallyAddFromAssetBundles").boolValue = dynamicallyAddFromAssetBundles;
					property.serializedObject.ApplyModifiedProperties ();
				}
				valR = new Rect (valR.xMin, valR.yMax + padding, valR.width, EditorGUIUtility.singleLineHeight);
				EditorGUI.PropertyField (valR,property.FindPropertyRelative ("assetBundleNames"), new GUIContent("AssetBundles to Search"));
				EditorGUI.indentLevel--;
			}
			EditorGUI.EndProperty ();
		}
 // Start is called before the first frame update
 void OnEnable()
 {
     playerAnim = playerAnimator.runtimeAnimatorController;
     playerAnimator.runtimeAnimatorController = null;
 }
Example #5
0
    /*
     * Awake
     */
    private void Awake()
    {
        animator        = GetComponent <Animator>();
        goToEmotionList = new List <GoToEmotionEntry>();

        // Create Playable Graph
        playableGraph = PlayableGraph.Create("ClairePlayableGraph");
        playableGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
        var playableOutput = AnimationPlayableOutput.Create(playableGraph, "Animation", animator);

        // Create Top Level Layer Mixer
        AnimationLayerMixerPlayable mixerLayerPlayable = AnimationLayerMixerPlayable.Create(playableGraph, 2);

        playableOutput.SetSourcePlayable(mixerLayerPlayable);

        // Create an Emotion Mixer
        int numberOfClips = 0;

        for (int i = 0; i < emotionObjects.Count; i++)
        {
            for (int j = 0; j < emotionObjects[i].animationGroupList.Count; j++)
            {
                if (emotionObjects[i].animationGroupList[j].main)
                {
                    numberOfClips++;
                }
                if (emotionObjects[i].animationGroupList[j].transitionIn)
                {
                    numberOfClips++;
                }
            }
        }
        mixerEmotionPlayable = AnimationMixerPlayable.Create(playableGraph, numberOfClips);    // Second argument sets number of inputs for clips to connect.

        // Wrap AnimController
        runtimeAnimController = animator.runtimeAnimatorController;
        var runtimeAnimControllerPlayable = AnimatorControllerPlayable.Create(playableGraph, runtimeAnimController);

        // Connect to Top Level Layer Mixer
        playableGraph.Connect(runtimeAnimControllerPlayable, 0, mixerLayerPlayable, 0);
        playableGraph.Connect(mixerEmotionPlayable, 0, mixerLayerPlayable, 1);
        mixerLayerPlayable.SetInputWeight(0, 1.0f);
        mixerLayerPlayable.SetInputWeight(1, 1.0f);
        mixerLayerPlayable.SetLayerMaskFromAvatarMask(1, headMask);
        //mixerLayerPlayable.SetLayerAdditive(1, true);

        // 1. Wraps each clip in a playable and connects them to the emotion mixer
        // 2. Also populate "playablesDict" to later be able to access the AnimationClipPlayables by their Index in the emotionMixer
        // 3. Main animations are not connected directly: Instead another MixerPlayable (mainMixer) is connected.
        //    The main playable is copied and both the original and copy are connected to the new MainMixer.
        //    This is to allow for smoothly looping main animations
        playablesDict = new Dictionary <string, int>();      // String: "Name"+"Index of Emotion Variation"; Int: Index in mixerEmotionPlayable
        int playablesCount     = 0;
        int tempPlayablesCount = 0;

        for (int i = 0; i < emotionObjects.Count; i++)
        {
            tempPlayablesCount = playablesCount;
            for (int j = 0; j < emotionObjects[i].animationGroupList.Count; j++)
            {
                if (emotionObjects[i].animationGroupList[j].main)
                {
                    playablesDict.Add(emotionObjects[i].name + j, playablesCount);
                    AnimationMixerPlayable mainMixer = AnimationMixerPlayable.Create(playableGraph, 2);
                    playableGraph.Connect(mainMixer, 0, mixerEmotionPlayable, playablesCount);
                    playablesCount++;

                    AnimationClipPlayable main = AnimationClipPlayable.Create(playableGraph, emotionObjects[i].animationGroupList[j].main);
                    playableGraph.Connect(main, 0, mainMixer, mainMixerMainIndex);
                    mainMixer.SetInputWeight(mainMixerMainIndex, 1.0f);  // Set first clip to active
                    main.SetDuration(emotionObjects[i].animationGroupList[j].main.length);

                    AnimationClipPlayable mainCopy = AnimationClipPlayable.Create(playableGraph, emotionObjects[i].animationGroupList[j].main);
                    playableGraph.Connect(mainCopy, 0, mainMixer, mainMixerCopyIndex);
                    mainMixer.SetInputWeight(mainMixerCopyIndex, 0.1f);  // Set second clip to inactive
                    mainCopy.SetDuration(emotionObjects[i].animationGroupList[j].main.length);
                }

                if (emotionObjects[i].animationGroupList[j].transitionIn)
                {
                    playablesDict.Add(emotionObjects[i].name + "TransitionIn" + j, playablesCount);
                    AnimationClipPlayable transition = AnimationClipPlayable.Create(playableGraph, emotionObjects[i].animationGroupList[j].transitionIn);
                    playableGraph.Connect(transition, 0, mixerEmotionPlayable, playablesCount);

                    transition.SetDuration(emotionObjects[i].animationGroupList[j].transitionIn.length);
                    playablesCount++;
                }
            }

            // If an emotion has any animationClips, it can be transitioned to
            if (tempPlayablesCount < playablesCount)
            {
                goToEmotionList.Add(new GoToEmotionEntry(emotionObjects[i].name, false, i));
            }
        }

        // Unrelated to Playables; For Display Purposes
        if (GOWithDrawGraphOnImage)
        {
            drawGraphOnImage = GOWithDrawGraphOnImage.GetComponent <DrawGraphOnImage>();
        }
    }
Example #6
0
        public static bool AnimationModifier(ChaControl __instance, ref string assetBundleName, ref string assetName, RuntimeAnimatorController __result)
        {
            Console.WriteLine($"{assetBundleName} exists: {File.Exists(assetBundleName)}");

            if (File.Exists(assetBundleName))
            {
                var runtimeAnimatorController = LoadAsset <RuntimeAnimatorController>(assetBundleName, assetName);
                __instance.animBody.runtimeAnimatorController = runtimeAnimatorController;
                __result = runtimeAnimatorController;
                return(false);
            }

            return(true);
        }
Example #7
0
        private static void OneLoadOK <T>(ref int _loadNum, string _mainHandWeaponJoint, string _offHandWeaponJoint, float _weaponScale, float _horseScale, string[] _particleJoints, GameObject _hero, RuntimeAnimatorController _animatorController, GameObject _mainHandWeapon, GameObject _offHandWeapon, GameObject _horse, GameObject[] _particles, GameObject[] _mainHandWeaponParticles, GameObject[] _offHandWeaponParticles, GameObject _wing, Action <GameObject> _callBack, bool _addHeroControl, bool isDownHouse) where T : HeroController
        {
            _loadNum--;

            if (_loadNum == 0)
            {
                AllLoadOK <T>(_mainHandWeaponJoint, _offHandWeaponJoint, _weaponScale, _horseScale, _particleJoints, _hero, _animatorController, _mainHandWeapon, _offHandWeapon, _horse, _particles, _mainHandWeaponParticles, _offHandWeaponParticles, _wing, _callBack, _addHeroControl, isDownHouse);
            }
        }
    /// <summary>
    /// Created the Third Person Controller
    /// </summary>
    void Create()
    {
        // base for the character
        var _3rdPerson = GameObject.Instantiate(charObj, Vector3.zero, Quaternion.identity) as GameObject;

        if (!_3rdPerson)
        {
            return;
        }

        _3rdPerson.name = "3rdPersonController";

        if (currentTemplate.templateType == CharacterTemplate.TemplateType.ThirdPerson)
        {
            _3rdPerson.AddComponent <ThirdPersonController> ();
        }
        else
        {
            _3rdPerson.AddComponent <TopDownController> ();
        }

        var footStep = _3rdPerson.AddComponent <FootStepFromTexture>();
        var collider = _3rdPerson.GetComponent <CapsuleCollider>();

        // rigidBody
        var rigidbody = _3rdPerson.GetComponent <Rigidbody>();

        rigidbody.constraints            = RigidbodyConstraints.FreezeRotation;
        rigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous;
        rigidbody.mass = 50;

        // capsule collider
        collider.height = ColliderHeight(_3rdPerson.GetComponent <Animator>());
        collider.center = new Vector3(0, (float)System.Math.Round(collider.height * 0.5f, 2), 0);
        collider.radius = (float)System.Math.Round(collider.height * 0.15f, 2);

        // animator
        _3rdPerson.GetComponent <Animator>().avatar     = _3rdPerson.GetComponent <Animator>().avatar;
        _3rdPerson.GetComponent <Animator>().updateMode = AnimatorUpdateMode.AnimatePhysics;
        var leftFT  = _3rdPerson.GetComponent <Animator>().GetBoneTransform(HumanBodyBones.LeftFoot).gameObject.AddComponent <SphereCollider>();
        var rightFT = _3rdPerson.GetComponent <Animator>().GetBoneTransform(HumanBodyBones.RightFoot).gameObject.AddComponent <SphereCollider>();

        controller = currentTemplate.animatorController;
        if (controller)
        {
            _3rdPerson.GetComponent <Animator>().runtimeAnimatorController = controller;
        }

        // footStep
        var _footStepSouce = new GameObject("footStepSource");

        _footStepSouce.transform.SetParent(_3rdPerson.transform);
        var sourceObj = new GameObject("sourceDefault", typeof(AudioSource));

        sourceObj.transform.SetParent(_footStepSouce.transform);
        sourceObj.GetComponent <AudioSource>().playOnAwake = false;
        footStep.defaultSurface        = new AudioSurface();
        footStep.defaultSurface.source = sourceObj.GetComponent <AudioSource>();
        footStep.leftFootTrigger       = leftFT;
        footStep.rightFootTrigger      = rightFT;

        // camera
        GameObject camera = null;

        if (Camera.main == null)
        {
            var cam = new GameObject("3rdPersonCamera");
            cam.AddComponent <Camera>();
            cam.AddComponent <FlareLayer>();
            // cam.AddComponent<GUILayer>();
            cam.AddComponent <AudioListener>();
            camera = cam;
            camera.GetComponent <Camera>().tag           = "MainCamera";
            camera.GetComponent <Camera>().nearClipPlane = 0.01f;
        }
        else
        {
            camera = Camera.main.gameObject;
            camera.gameObject.name = "3rdPersonCamera";
        }
        var tpcamera = camera.GetComponent <TPCamera>();

        if (tpcamera == null)
        {
            tpcamera = camera.AddComponent <TPCamera>();
        }

        // define the camera cursorObject
        tpcamera.target = _3rdPerson.transform;

        cameraListData = currentTemplate.cameraListData;
        if (cameraListData != null)
        {
            tpcamera.CameraStateList = cameraListData;
        }
        _3rdPerson.GetComponent <ThirdPersonMotor>().tpCamera = tpcamera;
        _3rdPerson.GetComponent <ThirdPersonMotor>().hud      = CreateHud();
        _3rdPerson.tag = "Player";
        this.Close();
    }
Example #9
0
        /// <summary>
        /// Shows the Character Builder options.
        /// </summary>
        private bool ShowGUI()
        {
            var modelType = (ModelType)EditorGUILayout.EnumPopup("Model Type", m_ModelType);

            if (modelType != m_ModelType)
            {
                m_ModelType = modelType;
                UpdateAnimatorController();
            }
            var canContinue = true;

            m_Character = EditorGUILayout.ObjectField("Character", m_Character, typeof(GameObject), true) as GameObject;
            if (m_Character == null)
            {
                EditorGUILayout.HelpBox("Select the GameObject which will be used as the character. This object will have the majority of the components added to it.",
                                        MessageType.Error);
                canContinue = false;
            }
            else if (PrefabUtility.GetPrefabType(m_Character) == PrefabType.Prefab)
            {
                EditorGUILayout.HelpBox("Please drag your character into the scene. The Character Builder cannot add components to prefabs.",
                                        MessageType.Error);
                canContinue = false;
            }

            if (m_ModelType == ModelType.Humanoid)
            {
                // Ensure the character is a humanoid.
                if (GUI.changed || m_CharacterUpdate)
                {
                    if (m_Character != null)
                    {
                        var character        = m_Character;
                        var spawnedCharacter = false;
                        // The character has to be spawned in order to be able to detect if it is a Humanoid.
                        if (AssetDatabase.GetAssetPath(m_Character).Length > 0)
                        {
                            character        = GameObject.Instantiate(character) as GameObject;
                            spawnedCharacter = true;
                        }
                        var animator    = character.GetComponent <Animator>();
                        var hasAnimator = animator != null;
                        if (!hasAnimator)
                        {
                            animator = character.AddComponent <Animator>();
                        }
                        // A human will have a head.
                        m_IsHumanoid = animator.GetBoneTransform(HumanBodyBones.Head) != null;
                        // Clean up.
                        if (!hasAnimator)
                        {
                            DestroyImmediate(animator, true);
                        }
                        if (spawnedCharacter)
                        {
                            DestroyImmediate(character, true);
                        }
                    }
                    m_CharacterUpdate = false;
                }

                if (m_Character != null && !m_IsHumanoid)
                {
                    EditorGUILayout.HelpBox(m_Character.name + " is not a humanoid. Please select the Humanoid Animation Type within the Rig Import Settings. " +
                                            "In addition, ensure all of the bones are configured correctly.", MessageType.Error);
                    canContinue = false;
                }
            }

            var movementType = (RigidbodyCharacterController.MovementType)EditorGUILayout.EnumPopup("Movement Type", m_MovementType);

            if (m_MovementType != movementType)
            {
                m_MovementType = movementType;
                UpdateAnimatorController();
            }
            m_AIAgent = EditorGUILayout.Toggle("Is AI Agent", m_AIAgent);
            EditorGUILayout.HelpBox("Is this character going to be used for AI? Some components (such as PlayerInput) do not need to be added if the character is an AI agent.",
                                    MessageType.Info);
#if DEATHMATCH_AI_KIT_PRESENT
            if (m_AIAgent)
            {
                m_DeathmatchAgent = EditorGUILayout.Toggle("Is Deathmatch Agent", m_DeathmatchAgent);
                EditorGUILayout.HelpBox("Is this character going to be used by the Deathmatch AI Kit?", MessageType.Info);
            }
#endif
#if !(UNITY_4_6 || UNITY_4_7 || UNITY_5_0)
            m_IsNetworked = EditorGUILayout.Toggle("Is Networked", m_IsNetworked);
            EditorGUILayout.HelpBox("Is this character going to be used on the network with Unity 5's multiplayer implementation?", MessageType.Info);
#endif
            if (m_ModelType == ModelType.Humanoid)
            {
                m_AddStandardAbilities = EditorGUILayout.Toggle("Add Standard Abilities", m_AddStandardAbilities);
                m_AddRagdoll           = EditorGUILayout.Toggle("Add Ragdoll", m_AddRagdoll);
                if (m_AddRagdoll)
                {
                    EditorGUILayout.HelpBox("Unity's Ragdoll Builder will open when this wizard is complete.", MessageType.Info);
                }
            }
            if (m_ModelType == ModelType.Generic || m_AnimatorController == null)
            {
                if (m_ModelType == ModelType.Humanoid)
                {
                    EditorGUILayout.HelpBox("Unable to find the built-in Animator Controller. Please select the controlled that your character should use.", MessageType.Warning);
                }
                m_AnimatorController = EditorGUILayout.ObjectField("Animator Controller", m_AnimatorController, typeof(RuntimeAnimatorController), true) as RuntimeAnimatorController;
                canContinue          = canContinue && m_ModelType == ModelType.Generic;
            }
            if (m_ModelType == ModelType.Generic)
            {
                m_SerializedObject.Update();
                EditorGUILayout.PropertyField(m_SerializedObject.FindProperty("m_ItemTransforms"), true);
                EditorGUILayout.PropertyField(m_SerializedObject.FindProperty("m_FootTransforms"), true);
                m_SerializedObject.ApplyModifiedProperties();
            }

            return(canContinue);
        }
 /// <summary>Constructs a new <see cref="Transition"/> with the specified Animator Controller and parameters.</summary>
 public Transition(RuntimeAnimatorController controller, string parameterNameX, string parameterNameY)
 {
     Controller      = controller;
     _ParameterNameX = parameterNameX;
     _ParameterNameY = parameterNameY;
 }
 public void transformation(RuntimeAnimatorController Monster, GameObject demonTile)
 {
     anim.SetBool("Transform", true);
     transforming = Monster;
     tile         = demonTile;
 }
            public void SetController(RuntimeAnimatorController controller)
            {
                if (DefaultClient.OptimizeForServer()) {
                    return;
                }

                animator.runtimeAnimatorController = controller;
            }
Example #13
0
 private void Awake()
 {
     loadedAnimatorController = Resources.Load <RuntimeAnimatorController>("ファイルパス");
 }
        private IEnumerator LoadSceneAsync(int index, bool stopTimeWhenLoading)
        {
            // Bool prevents the game from loading a level twice or multiple levels at the same time.
            isLoadingLevel = true;
            // Stop the time?
            Time.timeScale = stopTimeWhenLoading ? 0 : Time.timeScale;

            // Picks a random transition from the list of transitions.
            if (pickRandomTransition)
            {
                RuntimeAnimatorController randomTransitionAnim = transitionAnimators[UnityEngine.Random.Range(0, transitionAnimators.Count)];
                transitionAnim.runtimeAnimatorController = randomTransitionAnim;
            }

            // Set the transition speed and display a transition animation.
            transitionCanvas.enabled = true;
            transitionAnim.speed     = tSpeedIn;
            transitionAnim.Play("Transition In");

            // Wait for the transition to complete.
            while (!transitionComplete)
            {
                yield return(null);
            }
            transitionComplete = false;

            // Display the loading bar is showLoadingBar is set to true.
            loadingBar.SetActive(showLoadingBar ? true : false);

            // Load the level asynchronously and output the progress to the loading bar.
            AsyncOperation loadScene = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(index);

            while (!loadScene.isDone)
            {
                loadingBarFill.fillAmount = (loadScene.progress < 0.9f) ? loadScene.progress : 1;
                yield return(null);
            }

            // Deactivate the loading bar.
            loadingBar.SetActive(false);

            // Fires an OnLevelLoaded event so that all subscribed scripts can start doing their thing.
            OnLevelLoaded();

            // Set the transition speed and display another transition animation.
            transitionAnim.speed = tSpeedOut;
            transitionAnim.Play("Transition Out");

            // Wait for the transition to complete.
            while (!transitionComplete)
            {
                yield return(null);
            }
            transitionComplete       = false;
            transitionCanvas.enabled = false;

            // If the time was stopped, set it to one. If it wasn't stopped leave it as it is.
            Time.timeScale = stopTimeWhenLoading ? 1 : Time.timeScale;
            // Level has finished loading, another level can start loading if necessary.
            isLoadingLevel = false;
        }
 public AnimatorControllerPlayable(RuntimeAnimatorController controller)
   : base(false)
 {
   this.m_Ptr = IntPtr.Zero;
   this.InstantiateEnginePlayable(controller);
 }
Example #16
0
 internal static extern void InternalCreate(RuntimeAnimatorController controller, ref AnimatorControllerPlayable that);
Example #17
0
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member.

        /************************************************************************************************************************/
        #endregion
        /************************************************************************************************************************/
        #region Public API
        /************************************************************************************************************************/

        /// <summary>
        /// Constructs a new <see cref="ControllerState"/> to play the 'animatorController' without connecting
        /// it to the <see cref="PlayableGraph"/>. You must call <see cref="AnimancerState.SetParent"/> or it won't
        /// actually do anything.
        /// </summary>
        protected ControllerState(AnimancerPlayable root, RuntimeAnimatorController animatorController)
            : base(root)
        {
            CreatePlayable(animatorController);
        }
Example #18
0
    public static IEnumerator ChangeRuntimeAnimatorController(float timeToFinish, Animator animator, RuntimeAnimatorController runtimeAnimatorController)
    {
        yield return(new WaitForSeconds(timeToFinish));

        animator.runtimeAnimatorController = runtimeAnimatorController;
    }
Example #19
0
        public static void GetHero <T>(string _bodyPath, string _animatorControllerPath, bool _hasWeapon, string _mainHandWeaponPath, string _mainHandWeaponJoint, string[] _mainHandParticles, string _offHandWeaponPath, string _offHandWeaponJoint, string[] _offHandParticles, float _weaponScale, string _horsePath, string _horseAnimatorControllerPath, float _horseScale, string[] _particlePaths, string[] _particleJoints, string _wingPath, string _wingAnimatorControllerPath, Action <GameObject> _callBack, bool _addHeroControl, bool isDownHouse) where T : HeroController
        {
            GameObject hero = null;
            RuntimeAnimatorController animatorController = null;
            GameObject mainHandWeapon = null;
            GameObject offHandWeapon  = null;
            GameObject horse          = null;

            GameObject[] particles = null;
            GameObject[] mainHandWeaponParticles = null;
            GameObject[] offHandWeaponParticles  = null;
            GameObject   wing = null;

            int loadNum = 2;            //预先加的1  主体皮肤

            //加载AnimatorController
            Action <RuntimeAnimatorController> callBack2 = delegate(RuntimeAnimatorController result) {
                animatorController = result;

                AnimatorLoadOK(hero, result, _addHeroControl);

//                OneLoadOK<T>(ref loadNum, _mainHandWeaponJoint, _offHandWeaponJoint, _weaponScale, _horseScale, _particleJoints, hero, animatorController, mainHandWeapon, offHandWeapon, horse, particles, mainHandWeaponParticles, offHandWeaponParticles, wing, _callBack, _addHeroControl, isDownHouse);
            };

            AnimatorFactory.Instance.GetAnimator(_animatorControllerPath, callBack2);

            //加载主体
            Action <GameObject> callBack = delegate(GameObject _hero) {
                PublicTools.SetGameObjectVisible(_hero, false);

                hero = _hero;

                OneLoadOK <T>(ref loadNum, _mainHandWeaponJoint, _offHandWeaponJoint, _weaponScale, _horseScale, _particleJoints, hero, animatorController, mainHandWeapon, offHandWeapon, horse, particles, mainHandWeaponParticles, offHandWeaponParticles, wing, _callBack, _addHeroControl, isDownHouse);
            };

            if (!_addHeroControl)
            {
                GameObjectFactory.Instance.GetGameObject(_bodyPath, callBack, true);

                OneLoadOK <T>(ref loadNum, _mainHandWeaponJoint, _offHandWeaponJoint, _weaponScale, _horseScale, _particleJoints, hero, animatorController, mainHandWeapon, offHandWeapon, horse, particles, mainHandWeaponParticles, offHandWeaponParticles, wing, _callBack, _addHeroControl, isDownHouse);

                return;
            }

            //加载武器
            if (_hasWeapon)
            {
                List <string> weaponList      = new List <string>();
                List <string> jointList       = new List <string>();
                List <float>  weaponScaleList = new List <float>();

                if (!string.IsNullOrEmpty(_mainHandWeaponPath))
                {
                    if (MERGE_WEAPON)
                    {
                        weaponList.Add(_mainHandWeaponPath);
                        jointList.Add(_mainHandWeaponJoint);
                        weaponScaleList.Add(_weaponScale);
                    }
                    else
                    {
                        loadNum++;

                        Action <GameObject> weaponCallBack = delegate(GameObject _go) {
                            PublicTools.SetGameObjectVisible(_go, false);

                            mainHandWeapon = _go;

                            OneLoadOK <T>(ref loadNum, _mainHandWeaponJoint, _offHandWeaponJoint, _weaponScale, _horseScale, _particleJoints, hero, animatorController, mainHandWeapon, offHandWeapon, horse, particles, mainHandWeaponParticles, offHandWeaponParticles, wing, _callBack, _addHeroControl, isDownHouse);
                        };

                        GameObjectFactory.Instance.GetGameObject(_mainHandWeaponPath, weaponCallBack, true);
                    }

                    mainHandWeaponParticles = new GameObject[_mainHandParticles.Length];

                    for (int i = 0; i < _mainHandParticles.Length; i++)
                    {
                        loadNum++;

                        int particleIndex = i;

                        Action <GameObject> mainHandWeaponCallBack = delegate(GameObject _go) {
                            PublicTools.SetGameObjectVisible(_go, false);

                            mainHandWeaponParticles[particleIndex] = _go;

                            OneLoadOK <T>(ref loadNum, _mainHandWeaponJoint, _offHandWeaponJoint, _weaponScale, _horseScale, _particleJoints, hero, animatorController, mainHandWeapon, offHandWeapon, horse, particles, mainHandWeaponParticles, offHandWeaponParticles, wing, _callBack, _addHeroControl, isDownHouse);
                        };

                        GameObjectFactory.Instance.GetGameObject(_mainHandParticles[i], mainHandWeaponCallBack, true);
                    }
                }

                if (!string.IsNullOrEmpty(_offHandWeaponPath))
                {
                    if (MERGE_WEAPON)
                    {
                        weaponList.Add(_offHandWeaponPath);
                        jointList.Add(_offHandWeaponJoint);
                        weaponScaleList.Add(_weaponScale);
                    }
                    else
                    {
                        loadNum++;

                        Action <GameObject> weaponCallBack = delegate(GameObject _go) {
                            PublicTools.SetGameObjectVisible(_go, false);

                            offHandWeapon = _go;

                            OneLoadOK <T>(ref loadNum, _mainHandWeaponJoint, _offHandWeaponJoint, _weaponScale, _horseScale, _particleJoints, hero, animatorController, mainHandWeapon, offHandWeapon, horse, particles, mainHandWeaponParticles, offHandWeaponParticles, wing, _callBack, _addHeroControl, isDownHouse);
                        };

                        GameObjectFactory.Instance.GetGameObject(_offHandWeaponPath, weaponCallBack, true);
                    }

                    offHandWeaponParticles = new GameObject[_offHandParticles.Length];

                    for (int i = 0; i < _offHandParticles.Length; i++)
                    {
                        loadNum++;

                        int particleIndex = i;

                        Action <GameObject> offHandWeaponCallBack = delegate(GameObject _go) {
                            PublicTools.SetGameObjectVisible(_go, false);

                            offHandWeaponParticles[particleIndex] = _go;

                            OneLoadOK <T>(ref loadNum, _mainHandWeaponJoint, _offHandWeaponJoint, _weaponScale, _horseScale, _particleJoints, hero, animatorController, mainHandWeapon, offHandWeapon, horse, particles, mainHandWeaponParticles, offHandWeaponParticles, wing, _callBack, _addHeroControl, isDownHouse);
                        };

                        GameObjectFactory.Instance.GetGameObject(_offHandParticles[i], offHandWeaponCallBack, true);
                    }
                }

                if (MERGE_WEAPON)
                {
                    GameObjectFactory.Instance.GetGameObject(_bodyPath, callBack, weaponList.ToArray(), jointList.ToArray(), weaponScaleList.ToArray(), true, false);
                }
                else
                {
                    GameObjectFactory.Instance.GetGameObject(_bodyPath, callBack, true);
                }
            }
            else
            {
                GameObjectFactory.Instance.GetGameObject(_bodyPath, callBack, true);
            }

            //加载马
            if (!string.IsNullOrEmpty(_horsePath))
            {
                loadNum++;

                callBack = delegate(GameObject _go) {
                    PublicTools.SetGameObjectVisible(_go, false);

                    horse = _go;

                    OneLoadOK <T>(ref loadNum, _mainHandWeaponJoint, _offHandWeaponJoint, _weaponScale, _horseScale, _particleJoints, hero, animatorController, mainHandWeapon, offHandWeapon, horse, particles, mainHandWeaponParticles, offHandWeaponParticles, wing, _callBack, _addHeroControl, isDownHouse);
                };

                GetHero <T>(_horsePath, _horseAnimatorControllerPath, false, null, null, null, null, null, null, 0, null, null, 0, null, null, null, null, callBack, false, false);
            }

            //加载身上的粒子
            if (_particlePaths.Length > 0)
            {
                particles = new GameObject[_particlePaths.Length];

                for (int i = 0; i < _particlePaths.Length; i++)
                {
                    loadNum++;

                    int tmpIndex = i;

                    callBack = delegate(GameObject _go) {
                        PublicTools.SetGameObjectVisible(_go, false);

                        particles[tmpIndex] = _go;

                        OneLoadOK <T>(ref loadNum, _mainHandWeaponJoint, _offHandWeaponJoint, _weaponScale, _horseScale, _particleJoints, hero, animatorController, mainHandWeapon, offHandWeapon, horse, particles, mainHandWeaponParticles, offHandWeaponParticles, wing, _callBack, _addHeroControl, isDownHouse);
                    };

                    GameObjectFactory.Instance.GetGameObject(_particlePaths[i], callBack, true);
                }
            }

            //加载翅膀
            if (!string.IsNullOrEmpty(_wingPath))
            {
                loadNum++;

                callBack = delegate(GameObject _go){
                    PublicTools.SetGameObjectVisible(_go, false);

                    wing = _go;

                    OneLoadOK <T>(ref loadNum, _mainHandWeaponJoint, _offHandWeaponJoint, _weaponScale, _horseScale, _particleJoints, hero, animatorController, mainHandWeapon, offHandWeapon, horse, particles, mainHandWeaponParticles, offHandWeaponParticles, wing, _callBack, _addHeroControl, isDownHouse);
                };

                GetHero <T>(_wingPath, _wingAnimatorControllerPath, false, null, null, null, null, null, null, 0, null, null, 0, null, null, null, null, callBack, false, false);
            }

            OneLoadOK <T>(ref loadNum, _mainHandWeaponJoint, _offHandWeaponJoint, _weaponScale, _horseScale, _particleJoints, hero, animatorController, mainHandWeapon, offHandWeapon, horse, particles, mainHandWeaponParticles, offHandWeaponParticles, wing, _callBack, _addHeroControl, isDownHouse);
        }
 public abstract bool ChangeAction(RuntimeAnimatorController animatorController);
Example #21
0
        private static void AllLoadOK <T>(string _mainHandWeaponJoint, string _offHandWeaponJoint, float _weaponScale, float _horseScale, string[] _particleJoints, GameObject _hero, RuntimeAnimatorController _animatorController, GameObject _mainHandWeapon, GameObject _offHandWeapon, GameObject _horse, GameObject[] _particles, GameObject[] _mainHandWeaponParticles, GameObject[] _offHandWeaponParticles, GameObject _wing, Action <GameObject> _callBack, bool _addHeroControl, bool isDownHouse) where T : HeroController
        {
            Animator animator = _hero.GetComponent <Animator> ();

            if (animator.runtimeAnimatorController == null && _animatorController != null)
            {
                animator.runtimeAnimatorController = _animatorController;

                AnimatorFactory.Instance.AddUseNum(_animatorController);
            }

            if (_addHeroControl)
            {
                HeroController heroController = null;

                GameObject horseContainer = null;

                GameObject body = _hero.GetComponentInChildren <Renderer>().gameObject;

                HeroControllerDispatcher heroControllerDispatcher = _hero.GetComponent <HeroControllerDispatcher>();

                if (heroControllerDispatcher == null)
                {
                    _hero.AddComponent <HeroControllerDispatcher>();
                }

                if (_horse != null)
                {
                    horseContainer = new GameObject(_hero.name + "ma");

                    _horse.transform.SetParent(horseContainer.transform, false);

                    heroController = horseContainer.AddComponent <T> ();

                    heroController.horse = _horse.GetComponentInChildren <Renderer>().gameObject;

                    _horse.transform.localScale = new Vector3(_horseScale, _horseScale, _horseScale);

                    if (isDownHouse)
                    {
                        _hero.transform.localPosition = Vector3.zero;

                        _hero.transform.SetParent(horseContainer.transform, false);
                    }
                    else
                    {
                        GameObject bone = PublicTools.FindChild(_horse, HORSE_CHAIN_BONE_NAME);

                        bone.transform.localScale = new Vector3(1 / _horseScale, 1 / _horseScale, 1 / _horseScale);

                        _hero.transform.SetParent(bone.transform, true);

                        _hero.transform.localPosition = Vector3.zero;
                    }
                }
                else
                {
                    heroController = _hero.AddComponent <T> ();
                }

                heroController.body = body;

                if (_particles != null)
                {
                    for (int i = 0; i < _particles.Length; i++)
                    {
                        PublicTools.AddChild(_hero, _particles[i], _particleJoints[i]);
                    }

                    heroController.particles = _particles;
                }

                if (_mainHandWeapon != null)
                {
                    GameObject mainWeaponContainer = new GameObject();                    //为了让武器上的粒子配合武器进行缩放  所以添加了这个容器

                    mainWeaponContainer.name = "mainHandWeapon";

                    heroController.mainHandWeaponContainer = mainWeaponContainer;

                    mainWeaponContainer.transform.localScale = new Vector3(_weaponScale, _weaponScale, _weaponScale);

                    PublicTools.AddChild(_hero, mainWeaponContainer, _mainHandWeaponJoint);

                    if (!MERGE_WEAPON)
                    {
                        heroController.mainHandWeapon = _mainHandWeapon;

                        _mainHandWeapon.transform.SetParent(mainWeaponContainer.transform, false);
                    }

                    if (_mainHandWeaponParticles != null)
                    {
                        heroController.mainHandWeaponParticles = _mainHandWeaponParticles;

                        for (int i = 0; i < _mainHandWeaponParticles.Length; i++)
                        {
                            _mainHandWeaponParticles[i].transform.SetParent(mainWeaponContainer.transform, false);
                        }
                    }
                }

                if (_offHandWeapon != null)
                {
                    GameObject offWeaponContainer = new GameObject();                    //为了让武器上的粒子配合武器进行缩放  所以添加了这个容器

                    offWeaponContainer.name = "offHandWeapon";

                    heroController.offHandWeaponContainer = offWeaponContainer;

                    offWeaponContainer.transform.localScale = new Vector3(_weaponScale, _weaponScale, _weaponScale);

                    PublicTools.AddChild(_hero, offWeaponContainer, _offHandWeaponJoint);

                    if (!MERGE_WEAPON)
                    {
                        heroController.offHandWeapon = _offHandWeapon;

                        _offHandWeapon.transform.SetParent(offWeaponContainer.transform, false);
                    }

                    if (_offHandWeaponParticles != null)
                    {
                        heroController.offHandWeaponParticles = _offHandWeaponParticles;

                        for (int i = 0; i < _offHandWeaponParticles.Length; i++)
                        {
                            _offHandWeaponParticles[i].transform.SetParent(offWeaponContainer.transform, false);
                        }
                    }
                }

                if (_wing != null)
                {
                    GameObject heroDummy = PublicTools.FindChild(_hero, WING_DUMMY_NAME);
                    GameObject wingDummy = PublicTools.FindChild(_wing, WING_DUMMY_NAME);

                    _wing.transform.localPosition = (wingDummy.transform.worldToLocalMatrix * wingDummy.transform.parent.localToWorldMatrix).MultiplyPoint(_wing.transform.localPosition);

                    _wing.transform.SetParent(heroDummy.transform, false);

                    heroController.wing = _wing.GetComponentInChildren <Renderer>().gameObject;
                }

                heroController.Init();

                if (_horse != null)
                {
                    PublicTools.SetGameObjectVisible(horseContainer, true);

                    _callBack(horseContainer);
                }
                else
                {
                    PublicTools.SetGameObjectVisible(_hero, true);

                    _callBack(_hero);
                }
            }
            else
            {
                _callBack(_hero);
            }
        }
        //========================================
        //      Self-Define
        //------------------------------
        //----------------------
        // Public Functions

        /// <summary>
        /// Switch the animation state.
        /// </summary>
        /// <param name="type"> type of the animation. </param>
        public void SwitchState(JCS_CursorCustomizeType type)
        {
            RuntimeAnimatorController anim = null;

            bool notFound = false;

            switch (type)
            {
            case JCS_CursorCustomizeType.NORMAL_SELECT:
            {
                if (mNormalSelect == null)
                {
                    notFound = true;
                }

                anim = mNormalSelect;
            }
            break;

            case JCS_CursorCustomizeType.HELP_SELECT:
            {
                if (mHelpSelect == null)
                {
                    notFound = true;
                }

                anim = mHelpSelect;
            }
            break;

            case JCS_CursorCustomizeType.WORKING_IN_BACKGROUND:
            {
                if (mWorkingInBackground == null)
                {
                    notFound = true;
                }

                anim = mWorkingInBackground;
            }
            break;

            case JCS_CursorCustomizeType.BUSY:
            {
                if (mBusy == null)
                {
                    notFound = true;
                }

                anim = mBusy;
            }
            break;

            case JCS_CursorCustomizeType.PRECISION_SELECT:
            {
                if (mPrecisionSelect == null)
                {
                    notFound = true;
                }

                anim = mPrecisionSelect;
            }
            break;

            case JCS_CursorCustomizeType.TEXT_SELECT:
            {
                if (mTextSelect == null)
                {
                    notFound = true;
                }

                anim = mTextSelect;
            }
            break;

            case JCS_CursorCustomizeType.HANDWRITING:
            {
                if (mHandwriting == null)
                {
                    notFound = true;
                }

                anim = mHandwriting;
            }
            break;

            case JCS_CursorCustomizeType.UNAVAILABLE:
            {
                if (mUnavaliable == null)
                {
                    notFound = true;
                }

                anim = mUnavaliable;
            }
            break;

            case JCS_CursorCustomizeType.VERTICAL_RESIZE:
            {
                if (mVerticalResize == null)
                {
                    notFound = true;
                }

                anim = mVerticalResize;
            }
            break;

            case JCS_CursorCustomizeType.HORIZONTAL_RESIZE:
            {
                if (mHorizontalResize == null)
                {
                    notFound = true;
                }

                anim = mHorizontalResize;
            }
            break;

            case JCS_CursorCustomizeType.DIAGONAL_RESIZE_1:
            {
                if (mDiagonalResize1 == null)
                {
                    notFound = true;
                }

                anim = mDiagonalResize1;
            }
            break;

            case JCS_CursorCustomizeType.DIAGONAL_RESIZE_2:
            {
                if (mDiagonalResize2 == null)
                {
                    notFound = true;
                }

                anim = mDiagonalResize2;
            }
            break;

            case JCS_CursorCustomizeType.MOVE:
            {
                if (mMove == null)
                {
                    notFound = true;
                }

                anim = mMove;
            }
            break;

            case JCS_CursorCustomizeType.ALTERNATE_SELECT:
            {
                if (mAlternateSelect == null)
                {
                    notFound = true;
                }

                anim = mAlternateSelect;
            }
            break;

            case JCS_CursorCustomizeType.LINK_SELECT:
            {
                if (mNormalSelect == null)
                {
                    notFound = true;
                }

                anim = mLinkSelect;
            }
            break;
            }

            if (notFound)
            {
                JCS_Debug.LogError(
                    type.ToString() + " animation does not assign...");
                return;
            }

            // set animation
            mAnimator.runtimeAnimatorController = anim;

            this.mCursorCustomizeType = type;
        }
Example #23
0
        void PopPanel(PanelStack panelStack, Panel p, bool animate = true, RuntimeAnimatorController animController = null)
        {
            bool isTop = (p == panelStack.CurrentPanel);

            // Can only call PopPanel on the top panel

            /* rc - 11/28/2017: let panels get "popped" from
             * the middle of a stack. Most of the time the opposite
             * behaviour is unwanted (a middle panel taking anything that was
             * pushed after with it)
             * if (p != panelStack.CurrentPanel)
             * {
             *  return;
             * }*/

            AnalyticsHelper.FireEvent("PopPanel", new Dictionary <string, object>
            {
                { "Name", p.GetType().ToString() }
            });

            m_logger.Debug("PopPanel {0} ({1}) stack={2} start", p.name, p.GetType().Name, panelStack.m_stackName);

            panelStack.Remove(p);

            m_pushedPanelStacks.Remove(p);
            m_showPanels.Remove(p);

            var curr = panelStack.CurrentPanel;

            var onClose = p.OnClose;

            p.OnClose = null;

            if (onClose != null)
            {
                onClose();
            }

            if (!isTop)
            {
                // Skip animations, etc. The code
                // after this conditional is only
                // applicable when popping the top
                // panel
                SetPanelActive(p, false);

                p.DidPop();

                return;
            }

            // If the current top panel is the one that we remembered
            // from before. This handles the case that "onClose" caused
            // the same panel to be pushed again (e.g. screen message ->
            // screen message)
            if (panelStack.CurrentPanel && (panelStack.CurrentPanel == curr))
            {
                m_logger.Verbose("PopPanel from {0} -> {1} is ready={2}",
                                 p.GetType().Name, panelStack.CurrentPanel.GetType().Name, panelStack.CurrentPanel.IsReady);

                SetPanelActive(panelStack.CurrentPanel, true);
                panelStack.CurrentPanel.DidRegainTop();
            }

            SetPanelOrientation(curr);

            // Hide this panel last

            // We might be re-showing the same panel as part of the onClose flow,
            // if so, don't tell the panel it hid because this will shut the panel down.
            if (panelStack.CurrentPanel != p)
            {
                Action doPop = () =>
                {
                    var animCtl = animController ?? p.PopAnimation;

                    if (animCtl && animate)
                    {
                        p.DoAnimation(animCtl);
                    }
                    else
                    {
                        SetPanelActive(p, false);
                    }

                    p.DidPop();
                };

                if (panelStack.CurrentPanel && !panelStack.CurrentPanel.IsReady)
                {
                    m_logger.Verbose("Current panel {0} is not ready!", panelStack.CurrentPanel.name);

                    p.transform.SetAsLastSibling();

                    StartCoroutine(CallWhenReady(panelStack.CurrentPanel, () =>
                    {
                        // Make sure the panel we're disabling didn't become the
                        // current panel
                        if (p != panelStack.CurrentPanel)
                        {
                            doPop();
                        }
                    }));
                }
                else
                {
                    m_logger.Verbose("Current panel {0} is ready!", panelStack.CurrentPanel ? panelStack.CurrentPanel.name : null);

                    doPop();
                }
            }

            if (m_showPanels.Count == 0)
            {
                ObjectHelper.SetObjectsActive(ShowWhenPanelsShowing, false);
                ObjectHelper.SetObjectsActive(ShowWhenNoPanelsShowing, true);
            }

            m_logger.Verbose("PopPanel {0} end", p.GetType().Name);
        }
        /// <summary>
        /// Initialise this animation bridge.
        /// </summary>
        protected void Init()
        {
            // Get character reference
            myCharacter = (IMob)gameObject.GetComponent(typeof(IMob));
            if (myCharacter == null)
            {
                myCharacter = (IMob)gameObject.GetComponentInParent(typeof(IMob));
            }
            if (myCharacter == null)
            {
                Debug.LogError("Mecanim Animation Bridge (2D) unable to find Character or Enemy reference");
            }
            myCharacter.ChangeAnimationState += AnimationStateChanged;
            myAnimator = GetComponentInChildren <Animator>();
            if (myAnimator == null)
            {
                Debug.LogError("Platform Animator unable to find Unity Animator reference");
            }
            defaultController = myAnimator.runtimeAnimatorController;


            animationStateOverrideLookup = new Dictionary <string, AnimatorOverrideController> ();
            foreach (AnimatorControllerMapping mapping in mappings)
            {
                animationStateOverrideLookup.Add(mapping.overrrideState, mapping.controller);
            }

            queuedStates     = new Queue <AnimationState> ();
            queuedPriorities = new PriorityQueue();
            state            = AnimationState.NONE;
            priority         = -1;

            TimeManager.Instance.GamePaused   += HandleGamePaused;
            TimeManager.Instance.GameUnPaused += HandleGameUnPaused;

#if UNITY_EDITOR
                #if UNITY_5_3_OR_NEWER
            // In editor mode build a list of handled states for error messaging and the like
            if (myAnimator.runtimeAnimatorController is UnityEditor.Animations.AnimatorController)
            {
                editor_stateNames = new List <string>();
                UnityEditor.Animations.AnimatorStateMachine stateMachine = ((UnityEditor.Animations.AnimatorController)defaultController).layers[0].stateMachine;
                for (int i = 0; i < stateMachine.states.Length; i++)
                {
                    editor_stateNames.Add(stateMachine.states[i].state.name);
                }
            }
        #else
            // In editor mode build a list of handled states for error messaging and the like
            if (myAnimator.runtimeAnimatorController is UnityEditorInternal.AnimatorController)
            {
                editor_stateNames = new List <string>();
                UnityEditorInternal.StateMachine stateMachine = ((UnityEditorInternal.AnimatorController)defaultController).GetLayer(0).stateMachine;
                for (int i = 0; i < stateMachine.stateCount; i++)
                {
                    editor_stateNames.Add(stateMachine.GetState(i).name);
                }
            }
        #endif
#endif
        }
Example #25
0
        /// <summary>
        /// Play the lightning animation once.
        /// </summary>
        private void PlayLightningAnim()
        {
            RuntimeAnimatorController con = this.mAnimPool.GetRandomAnim();

            mAnimator.runtimeAnimatorController = con;
        }
Example #26
0
        public void LinkPortrait(apPortrait portrait, apAnimPlayManager animPlayManager)
        {
            _portrait        = portrait;
            _animPlayManager = animPlayManager;

            _animator        = _portrait._animator;
            _animController  = null;
            _isValidAnimator = false;

            if (_animator == null)
            {
                //Debug.LogError("No Animator");

                return;
            }

            _animController = _animator.runtimeAnimatorController;

#if UNITY_2017_1_OR_NEWER
            //추가 3.5 : Unity 2017부터 추가된 "Timeline"기능에 대한 연동 객체이다.
            if (_timlinePlay == null)
            {
                _timlinePlay = new apAnimPlayTimeline();
            }

            _timlinePlay.Link(portrait, animPlayManager, this);
#endif

            if (_animController == null)
            {
                //변경 : 타임라인을 위해서 Mecanim을 사용하는 경우, RuntimeAnimatorController가 필요없을 수 있다.
                //Debug.LogError("AnyPortrait : No RuntimeAnimatorController on Animator");
                return;
            }

            _isValidAnimator = true;

            _layers.Clear();
            _clipData.Clear();
            _clipDataByAsset.Clear();
            _clipDataByAnimClip.Clear();

            //레이어 정보를 담자
            _nLayers = _animator.layerCount;

            //저장된 AnimClip 체크를 위해서 리스트를 만들자
            //유효하지 않은 AnimClip은 제외해야한다.
            List <AnimationClip> allClips   = new List <AnimationClip>();
            List <AnimationClip> validClips = new List <AnimationClip>();


            for (int iLayer = 0; iLayer < _animator.layerCount; iLayer++)
            {
                MecanimLayer newLayer = new MecanimLayer();
                newLayer._index = iLayer;

                newLayer._blendType = apAnimPlayUnit.BLEND_METHOD.Interpolation;

                if (iLayer < portrait._animatorLayerBakedData.Count)
                {
                    if (portrait._animatorLayerBakedData[iLayer]._blendType == apAnimMecanimData_Layer.MecanimLayerBlendType.Additive)
                    {
                        //미리 설정된 데이터가 있고, Additive라면 Additive로 설정
                        newLayer._blendType = apAnimPlayUnit.BLEND_METHOD.Additive;
                    }
                }

                _layers.Add(newLayer);
            }

            //어떤 AnimClip이 있는지 체크하자
            for (int i = 0; i < _animController.animationClips.Length; i++)
            {
                if (!allClips.Contains(_animController.animationClips[i]))
                {
                    allClips.Add(_animController.animationClips[i]);
                }
            }


            //apAnimClip <-> AnimationClip Asset을 서로 연결하자
            _animClip2Asset.Clear();
            _asset2AnimClip.Clear();

            //Debug.Log("animPlayManager._animPlayDataList Count : " + animPlayManager._animPlayDataList.Count);

            for (int i = 0; i < animPlayManager._animPlayDataList.Count; i++)
            {
                apAnimPlayData playData = animPlayManager._animPlayDataList[i];
                //Debug.Log("[" + i + "] : " + playData._animClipName);
                apAnimClip animClip = playData._linkedAnimClip;
                if (animClip == null)
                {
                    //Debug.LogError("[" + i + "] : " + playData._animClipName + " >> Linked Anim Clip is Null");
                    continue;
                }
                AnimationClip assetClip = animClip._animationClipForMecanim;

                if (assetClip != null)
                {
                    _animClip2Asset.Add(animClip, assetClip);
                    _asset2AnimClip.Add(assetClip, animClip);

                    MecanimClipData newClipData = new MecanimClipData(assetClip, animClip, playData._linkedOptRootUnit);
                    _clipData.Add(newClipData);
                    _clipDataByAsset.Add(assetClip, newClipData);
                    _clipDataByAnimClip.Add(animClip, newClipData);

                    if (!validClips.Contains(assetClip))
                    {
                        validClips.Add(assetClip);
                    }
                    //Debug.Log("[" + i + "] : " + playData._animClipName + " >> " + assetClip.name);
                }
                else
                {
                    if (Application.isPlaying)
                    {
                        Debug.LogError("[" + i + "] : " + playData._animClipName + " >> AnimAsset is Null");
                    }
                }
            }

            _nClipData = _clipData.Count;

            //여기서 유효성 체크
            //(유효성 체크는 Application 실행 시에)
            //if (Application.isPlaying)
            {
                for (int i = 0; i < allClips.Count; i++)
                {
                    if (!validClips.Contains(allClips[i]))
                    {
                        if (allClips[i] != _portrait._emptyAnimClipForMecanim)
                        {
                            //유효하지 않은 Clip이 발견되었다.
                            Debug.LogError("AnyPortrait : ( Caution! ) Contains an invalid AnimationClip. An error may occur when playing. [" + allClips[i].name + " < " + _portrait.gameObject.name + "]");
                            Debug.LogError("Valid Clips : " + validClips.Count);
                        }
                    }
                }
            }
        }
 /// <summary>
 /// 改變此套裝的AOC
 /// </summary>
 /// <param name="_aoc"></param>
 public void ChangeAOC(AnimatorOverrideController _aoc)
 {
     currentNormalController = Behavior.Animator.runtimeAnimatorController;
     Behavior.Animator.runtimeAnimatorController = _aoc;
 }
    private void Start()
    {
        float num = 0f;

        if (base.gameObject.GetComponent <ParticleSystem>() != null)
        {
            ParticleSystem component = base.gameObject.GetComponent <ParticleSystem>();
            if (component.startDelay + component.duration > num)
            {
                num = component.startDelay + component.duration;
            }
            if (component != null && component.maxParticles > this.maxParticles)
            {
                if (QualitySettings.GetQualityLevel() == 0)
                {
                    component.maxParticles = 100;
                }
                else if (QualitySettings.GetQualityLevel() == 1)
                {
                    component.maxParticles = 50;
                }
                else if (QualitySettings.GetQualityLevel() == 2)
                {
                    component.maxParticles = 10;
                }
            }
        }
        ParticleSystem[] componentsInChildren = base.gameObject.GetComponentsInChildren <ParticleSystem>();
        for (int i = 0; i < componentsInChildren.Length; i++)
        {
            if (componentsInChildren[i].startDelay + componentsInChildren[i].duration > num)
            {
                num = componentsInChildren[i].startDelay + componentsInChildren[i].duration;
            }
            if (componentsInChildren[i] != null && componentsInChildren[i].maxParticles > this.maxParticles)
            {
                if (QualitySettings.GetQualityLevel() == 0)
                {
                    componentsInChildren[i].maxParticles = 100;
                }
                else if (QualitySettings.GetQualityLevel() == 1)
                {
                    componentsInChildren[i].maxParticles = 50;
                }
                else if (QualitySettings.GetQualityLevel() == 2)
                {
                    componentsInChildren[i].maxParticles = 10;
                }
            }
        }
        Animator[] componentsInChildren2 = base.gameObject.transform.GetComponentsInChildren <Animator>();
        for (int j = 0; j < componentsInChildren2.Length; j++)
        {
            RuntimeAnimatorController runtimeAnimatorController = componentsInChildren2[j].runtimeAnimatorController;
            for (int k = 0; k < runtimeAnimatorController.animationClips.Length; k++)
            {
                if (runtimeAnimatorController.animationClips[k].length > num)
                {
                    num = runtimeAnimatorController.animationClips[k].length;
                }
            }
        }
        AutoDestroy autoDestroy = base.GetComponent <AutoDestroy>();

        if (autoDestroy == null)
        {
            autoDestroy          = base.gameObject.AddComponent <AutoDestroy>();
            autoDestroy.lifetime = ((num != 0f) ? num : 2f);
        }
    }
        /// <summary>
        ///
        /// </summary>
        /// <param name="prefabName"></param>
        /// <param name="contentPrefabName"></param>
        /// <param name="contentPrefab"></param>
        /// <param name="contentSiblingIndex"></param>
        /// <param name="runtimeAnimatorController"></param>
        /// <param name="prefab"></param>
        /// <returns></returns>
        public DialogInstance Create(GameObject prefab, string prefabName, GameObject contentPrefab, string contentPrefabName, int contentSiblingIndex = 2, RuntimeAnimatorController runtimeAnimatorController = null)
        {
            // create and get dialog Instance
            var dialogInstance = prefab != null?Create(prefab) : Create(prefabName);

            // if no content prefab then get from name if specified.
            if (contentPrefab == null && contentPrefabName != null)
            {
                contentPrefab = GetPrefab("Content/" + contentPrefabName);
                Assert.IsNotNull(contentPrefab, "Unable to find named content prefab 'Content/" + contentPrefabName + "'");
            }

            // add custom content
            if (contentPrefab != null)
            {
                dialogInstance.CustomContentItem      = Instantiate(contentPrefab);
                dialogInstance.CustomContentItem.name = contentPrefab.name;                           // copy name so animation work.
                dialogInstance.CustomContentItem.transform.SetParent(dialogInstance.Content.transform, false);
                dialogInstance.CustomContentItem.transform.localPosition = Vector3.zero;
                if (contentSiblingIndex != -1)
                {
                    dialogInstance.CustomContentItem.transform.SetSiblingIndex(contentSiblingIndex);
                }
            }

            // add custom content animator
            if (runtimeAnimatorController != null)
            {
                dialogInstance.ContentAnimator.runtimeAnimatorController = runtimeAnimatorController;
            }

            return(dialogInstance);
        }
        private IEnumerator LoadSceneAsync(int index, bool stopTimeWhenLoading)
        {
            // Bool prevents the game from loading a level twice or multiple levels at the same time.
            isLoadingLevel = true;
            // Stop the time?
            Time.timeScale = stopTimeWhenLoading ? 0 : Time.timeScale;

            // Picks a random transition from the list of transitions.
            if (pickRandomTransition)
            {
                RuntimeAnimatorController randomTransitionAnim = transitionAnimators[UnityEngine.Random.Range(0, transitionAnimators.Count)];
                transitionAnim.runtimeAnimatorController = randomTransitionAnim;
            }

            // Set the transition speed and display a transition animation.
            transitionAnim.speed = tSpeedIn;
            transitionAnim.Play("Transition In");

            // Wait for the transition to complete.
            while (!transitionComplete)
            {
                yield return(null);
            }
            transitionComplete = false;

            // Display the loading bar is showLoadingBar is set to true.
            if (showLoadingBar)
            {
                loadingBar.SetActive(true);
            }

            loadingHubText.SetActive(index == 1 ? true : false);

            // Load the level asynchronously and output the progress to the loading bar.
            AsyncOperation loadScene = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(index);

            while (!loadScene.isDone)
            {
                loadingBarFill.fillAmount = (loadScene.progress < 0.9f) ? loadScene.progress : 1;
                yield return(null);
            }

            if (loadingHubText.activeInHierarchy && Photon.Pun.PhotonNetwork.IsConnected)
            {
                // Havent figured out a clean way to do this so for now when were loading the hub i'll wait a little bit longer for the ObjectPooler and buffered RPC's to finish their thing.
                yield return(new WaitForSeconds(0.5f));
            }

            // Deactivate the loading bar.
            loadingBar.SetActive(false);
            loadingHubText.SetActive(false);

            // Set the transition speed and display another transition animation.
            transitionAnim.speed = tSpeedOut;
            transitionAnim.Play("Transition Out");

            // Wait for the transition to complete.
            while (!transitionComplete)
            {
                yield return(null);
            }
            transitionComplete = false;

            // If the time was stopped, set is to one. If it wasn't stopped leave it as it is.
            Time.timeScale = stopTimeWhenLoading ? 1 : Time.timeScale;
            // Level has finished loading, another level can start loading if necessary.
            isLoadingLevel = false;
            // Fires an OnLevelLoaded event so that all subscribed scripts can start doing their thing.
            OnLevelLoaded();
        }
 public void Construct(WeaponType weaponType, RuntimeAnimatorController animationController, Sprite sprite)
 {
     WeaponType = weaponType;
     AnimationController = animationController;
     Sprite = sprite;
 }
    void OnGUI()
    {
        if (!skin)
        {
            skin = Resources.Load("skin") as GUISkin;
        }
        GUI.skin = skin;

        this.minSize      = rect;
        this.titleContent = new GUIContent("Character", null, "Third Person Character Creator");

        GUILayout.BeginVertical("Character Creator Window", "window");
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        GUILayout.BeginVertical("box");

        if (!charObj)
        {
            EditorGUILayout.HelpBox("Make sure your FBX model is set as Humanoid!", MessageType.Info);
        }
        else if (!charExist)
        {
            EditorGUILayout.HelpBox("Missing a Animator Component", MessageType.Error);
        }
        else if (!isHuman)
        {
            EditorGUILayout.HelpBox("This is not a Humanoid", MessageType.Error);
        }
        else if (!isValidAvatar)
        {
            EditorGUILayout.HelpBox(charObj.name + " is a invalid Humanoid", MessageType.Info);
        }

        charObj = EditorGUILayout.ObjectField("FBX Model", charObj, typeof(GameObject), true, GUILayout.ExpandWidth(true)) as GameObject;

        if (GUI.changed && charObj != null && charObj.GetComponent <vThirdPersonController>() == null)
        {
            humanoidpreview = Editor.CreateEditor(charObj);
        }
        if (charObj != null && charObj.GetComponent <vThirdPersonController>() != null)
        {
            EditorGUILayout.HelpBox("This gameObject already contains the component vThirdPersonController", MessageType.Warning);
        }

        controller     = EditorGUILayout.ObjectField("Animator Controller: ", controller, typeof(RuntimeAnimatorController), false) as RuntimeAnimatorController;
        cameraListData = EditorGUILayout.ObjectField("Camera List Data: ", cameraListData, typeof(vThirdPersonCameraListData), false) as vThirdPersonCameraListData;
        hud            = EditorGUILayout.ObjectField("Hud Controller: ", hud, typeof(GameObject), false) as GameObject;
        if (hud != null && hud.GetComponent <vHUDController>() == null)
        {
            EditorGUILayout.HelpBox("This object does not contain a vHUDController", MessageType.Warning);
        }
        GUILayout.EndVertical();

        GUILayout.BeginHorizontal("box");
        EditorGUILayout.LabelField("Need to know how it works?");
        if (GUILayout.Button("Video Tutorial"))
        {
            Application.OpenURL("https://www.youtube.com/watch?v=KQ5xha36tfE&index=1&list=PLvgXGzhT_qehtuCYl2oyL-LrWoT7fhg9d");
        }
        GUILayout.EndHorizontal();

        if (charObj)
        {
            charAnimator = charObj.GetComponent <Animator>();
        }
        charExist     = charAnimator != null;
        isHuman       = charExist ? charAnimator.isHuman : false;
        isValidAvatar = charExist ? charAnimator.avatar.isValid : false;

        if (CanCreate())
        {
            DrawHumanoidPreview();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (controller != null)
            {
                if (GUILayout.Button("Create"))
                {
                    Create();
                }
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }

        GUILayout.EndVertical();
    }
 private void InstantiateEnginePlayable(RuntimeAnimatorController controller);
Example #34
0
        /************************************************************************************************************************/

        /// <summary>Destroys the <see cref="Playable"/>.</summary>
        public override void Dispose()
        {
            _Controller = null;
            base.Dispose();
        }