private void Update() { var material = GetComponent <Renderer>().material; Color color = Color.magenta; material.color = SampleUtility.FadeEffectorColorByWeight(color, weight); }
public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter) { if (!IsEnabled(logLevel)) { return; } var message = formatter(state, exception); if (string.IsNullOrEmpty(message)) { return; } if (exception != null) { message += "\n" + exception; } var eventLog = new EventLog { Message = message, EventId = eventId.Id, LogLevel = logLevel.ToString(), CreatedTime = DateTime.UtcNow, IpAdress = SampleUtility.GetIp4Adress(), HostName = Dns.GetHostName() }; InsertLog(eventLog); }
void OnEnable() { m_Animator = GetComponent <Animator>(); // Setting to Always animate because on the first frame the renderer can be not visible which break syncGoal on start up m_Animator.cullingMode = AnimatorCullingMode.AlwaysAnimate; if (!m_Animator.avatar.isHuman) { throw new InvalidOperationException("Avatar must be a humanoid."); } m_Graph = PlayableGraph.Create(); m_Graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime); var output = AnimationPlayableOutput.Create(m_Graph, "output", m_Animator); var clip = SampleUtility.LoadAnimationClipFromFbx("DefaultMale/Models/DefaultMale_Humanoid", "Idle"); var clipPlayable = AnimationClipPlayable.Create(m_Graph, clip); clipPlayable.SetApplyFootIK(false); clipPlayable.SetApplyPlayableIK(false); var job = new FullBodyIKJob(); job.stiffness = stiffness; job.maxPullIteration = maxPullIteration; SetupIKLimbHandle(ref job.leftArm, HumanBodyBones.LeftUpperArm, HumanBodyBones.LeftLowerArm, HumanBodyBones.LeftHand); SetupIKLimbHandle(ref job.rightArm, HumanBodyBones.RightUpperArm, HumanBodyBones.RightLowerArm, HumanBodyBones.RightHand); SetupIKLimbHandle(ref job.leftLeg, HumanBodyBones.LeftUpperLeg, HumanBodyBones.LeftLowerLeg, HumanBodyBones.LeftFoot); SetupIKLimbHandle(ref job.rightLeg, HumanBodyBones.RightUpperLeg, HumanBodyBones.RightLowerLeg, HumanBodyBones.RightFoot); m_LeftFootEffector = SetupEffector(ref job.leftFootEffector, "LeftFootEffector"); m_RightFootEffector = SetupEffector(ref job.rightFootEffector, "RightFootEffector"); m_LeftHandEffector = SetupEffector(ref job.leftHandEffector, "LeftHandEffector"); m_RightHandEffector = SetupEffector(ref job.rightHandEffector, "RightHandEffector"); m_LeftKneeHintEffector = SetupHintEffector(ref job.leftKneeHintEffector, "LeftKneeHintEffector"); m_RightKneeHintEffector = SetupHintEffector(ref job.rightKneeHintEffector, "RightKneeHintEffector"); m_LeftElbowHintEffector = SetupHintEffector(ref job.leftElbowHintEffector, "LeftElbowHintEffector"); m_RightElbowHintEffector = SetupHintEffector(ref job.rightElbowHintEffector, "RightElbowHintEffector"); m_LookAtEffector = SetupLookAtEffector(ref job.lookAtEffector, "LookAtEffector"); m_BodyRotationEffector = SetupBodyEffector(ref job.bodyEffector, "BodyEffector"); m_IKPlayable = AnimationScriptPlayable.Create <FullBodyIKJob>(m_Graph, job, 1); m_IKPlayable.ConnectInput(0, clipPlayable, 0, 1.0f); output.SetSourcePlayable(m_IKPlayable); m_Graph.Play(); m_Graph.Evaluate(0); SyncIKFromPose(); ResetIKWeight(); }
private void Update() { float averageWeight = (positionWeight + rotationWeight + pullWeight) / 3.0f; var material = GetComponent <Renderer>().material; Color color = Color.magenta; material.color = SampleUtility.FadeEffectorColorByWeight(color, averageWeight); }
private void Update() { float weight = (eyesWeight + headWeight + bodyWeight + clampWeight) / 4.0f; var material = GetComponent <Renderer>().material; Color color = Color.magenta; material.color = SampleUtility.FadeEffectorColorByWeight(color, weight); }
private void RefreshAccess() { m_info.m_readMe = ReadMeUtility.GetReadMeFile(m_selector); m_info.m_sample = SampleUtility.GetSampleFolder(m_selector); m_info.m_documentation = DocumentationUtility.GetDocumentFolder(m_selector); m_info.m_changelog = ChangeLogUtility.GetReadMeFile(m_selector); m_info.m_license = LicenseUtility.GetReadMeFile(m_selector); QuickGit.GetGitInDirectory(m_selector.GetAbsolutePath(true), out m_info.m_gitLink, false); }
void OnEnable() { // Load animation clips. var idleClip = SampleUtility.LoadAnimationClipFromFbx("DefaultMale/Models/DefaultMale_Generic", "Idle"); var romClip = SampleUtility.LoadAnimationClipFromFbx("DefaultMale/Models/DefaultMale_Generic", "ROM"); if (idleClip == null || romClip == null) { return; } var animator = GetComponent <Animator>(); // Get all the transforms in the hierarchy. var transforms = animator.transform.GetComponentsInChildren <Transform>(); var numTransforms = transforms.Length - 1; // Fill native arrays (all the bones have a weight of 1.0). m_Handles = new NativeArray <TransformStreamHandle>(numTransforms, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); m_BoneWeights = new NativeArray <float>(numTransforms, Allocator.Persistent, NativeArrayOptions.ClearMemory); for (var i = 0; i < numTransforms; ++i) { m_Handles[i] = animator.BindStreamTransform(transforms[i + 1]); m_BoneWeights[i] = 1.0f; } // Create job. var job = new MixerJob() { handles = m_Handles, boneWeights = m_BoneWeights, weight = 0.0f }; // Create graph with custom mixer. m_Graph = PlayableGraph.Create("SimpleMixer"); m_Graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime); m_CustomMixerPlayable = AnimationScriptPlayable.Create(m_Graph, job); m_CustomMixerPlayable.SetProcessInputs(false); AnimationClipPlayable idlePlayable = CreateAnimationPlayableClip(m_Graph, idleClip); AnimationClipPlayable romPlayable = CreateAnimationPlayableClip(m_Graph, romClip); m_CustomMixerPlayable.AddInput(idlePlayable, 0, 1.0f); m_CustomMixerPlayable.AddInput(romPlayable, 0, 1.0f); var output = AnimationPlayableOutput.Create(m_Graph, "output", animator); output.SetSourcePlayable(m_CustomMixerPlayable); m_Graph.Play(); emptyGraph = PlayableGraph.Create("EmptyGraph"); emptyGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime); }
private static void LoadSamplesFromDirectoryToPackage(UnityPathSelectionInfo selection, ref PackageBuildInformation package) { SampleDirectoryStream samplesDir = SampleUtility.GetSampleFolder(selection); string[] folders = SampleUtility.GetRelativeFoldersIn(samplesDir); for (int i = 0; i < folders.Length; i++) { string name = folders[i]; name = UnityPaths.GetLastPartOfPath(name); package.m_samples.m_samples.Add(new SampleInfo() { m_displayName = name, m_assetRelativePath = folders[i], m_description = "" }); } }
void OnEnable() { if (joints.Length == 0) { return; } var animator = GetComponent <Animator>(); // Create job. Initialize(animator); var dampingJob = new DampingJob() { rootHandle = animator.BindStreamTransform(transform), jointHandles = m_Handles, localPositions = m_LocalPositions, localRotations = m_LocalRotations, positions = m_Positions, velocities = m_Velocities }; // Create graph. m_Graph = PlayableGraph.Create("Damping"); m_Graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime); m_DampingPlayable = AnimationScriptPlayable.Create(m_Graph, dampingJob); var output = AnimationPlayableOutput.Create(m_Graph, "output", animator); output.SetSourcePlayable(m_DampingPlayable); // Start the graph. m_Graph.Play(); // Create effectors for each joints. m_JointEffectors = new List <GameObject>(joints.Length); foreach (var joint in joints) { var effector = SampleUtility.CreateEffector(joint.name, joint.position, joint.rotation); effector.hideFlags |= HideFlags.HideInHierarchy; m_JointEffectors.Add(effector); } }
void OnEnable() { var idleClip = SampleUtility.LoadAnimationClipFromFbx("DefaultMale/Models/DefaultMale_Generic", "Idle"); if (idleClip == null) { return; } if (endJoint == null) { return; } m_MidJoint = endJoint.parent; if (m_MidJoint == null) { return; } m_TopJoint = m_MidJoint.parent; if (m_TopJoint == null) { return; } m_Effector = SampleUtility.CreateEffector("Effector_" + endJoint.name, endJoint.position, endJoint.rotation); m_Graph = PlayableGraph.Create("TwoBoneIK"); m_Graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime); var output = AnimationPlayableOutput.Create(m_Graph, "ouput", GetComponent <Animator>()); var twoBoneIKJob = new TwoBoneIKJob(); twoBoneIKJob.Setup(GetComponent <Animator>(), m_TopJoint, m_MidJoint, endJoint, m_Effector.transform); m_IKPlayable = AnimationScriptPlayable.Create(m_Graph, twoBoneIKJob); m_IKPlayable.AddInput(AnimationClipPlayable.Create(m_Graph, idleClip), 0, 1.0f); output.SetSourcePlayable(m_IKPlayable); m_Graph.Play(); }
void OnEnable() { var idleClip = SampleUtility.LoadAnimationClipFromFbx("Chomper/Animations/@ChomperIdle", "Cooldown"); if (idleClip == null) { return; } if (joint == null) { return; } var targetPosition = joint.position + gameObject.transform.rotation * Vector3.forward; m_Target = SampleUtility.CreateEffector("Effector_" + joint.name, targetPosition, Quaternion.identity); m_Graph = PlayableGraph.Create("TwoBoneIK"); m_Graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime); var output = AnimationPlayableOutput.Create(m_Graph, "ouput", GetComponent <Animator>()); var animator = GetComponent <Animator>(); animator.fireEvents = false; var lookAtJob = new LookAtJob() { joint = animator.BindStreamTransform(joint), target = animator.BindSceneTransform(m_Target.transform), axis = GetAxisVector(axis), minAngle = Mathf.Min(minAngle, maxAngle), maxAngle = Mathf.Max(minAngle, maxAngle) }; m_LookAtPlayable = AnimationScriptPlayable.Create(m_Graph, lookAtJob); m_LookAtPlayable.AddInput(AnimationClipPlayable.Create(m_Graph, idleClip), 0, 1.0f); output.SetSourcePlayable(m_LookAtPlayable); m_Graph.Play(); }
private void ToggleAndCreateHiddenFolder() { GUILayout.BeginHorizontal(); GUILayout.Label("Create:", EditorStyles.boldLabel); if (GUILayout.Button("Documentation")) { DocumentationUtility.Create(m_selector, false); Refresh(); } if (GUILayout.Button("Samples")) { SampleUtility.Create(m_selector, false); Refresh(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Toogle:", EditorStyles.boldLabel); if (GUILayout.Button("Documentation")) { DocumentationUtility.Toggle(m_selector); Refresh(); } if (GUILayout.Button("Samples")) { SampleUtility.Toggle(m_selector); Refresh(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Delete:", EditorStyles.boldLabel); if (GUILayout.Button("Documentation")) { m_info.m_documentation.Delete(); Refresh(); } if (GUILayout.Button("Samples")) { m_info.m_sample.Delete(); Refresh(); } GUILayout.EndHorizontal(); }
private static GameObject CreateBodyEffector(string name) { var go = SampleUtility.CreateBodyEffector(name, Vector3.zero, Quaternion.identity); return(go); }
void OnEnable() { // Load animation clips. var idleClip = SampleUtility.LoadAnimationClipFromFbx("DefaultMale/Models/DefaultMale_Generic", "Idle"); var romClip = SampleUtility.LoadAnimationClipFromFbx("DefaultMale/Models/DefaultMale_Generic", "ROM"); if (idleClip == null || romClip == null) { return; } var animator = GetComponent <Animator>(); // Get all the transforms in the hierarchy. var allTransforms = animator.transform.GetComponentsInChildren <Transform>(); var numTransforms = allTransforms.Length - 1; // Fill native arrays (all the bones have a weight of 0.0). m_Handles = new NativeArray <TransformStreamHandle>(numTransforms, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); m_BoneWeights = new NativeArray <float>(numTransforms, Allocator.Persistent, NativeArrayOptions.ClearMemory); for (var i = 0; i < numTransforms; ++i) { m_Handles[i] = animator.BindStreamTransform(allTransforms[i + 1]); } // Set bone weights for selected transforms and their hierarchy. m_BoneChildrenIndices = new List <List <int> >(boneTransformWeights.Length); foreach (var boneTransform in boneTransformWeights) { var childrenTransforms = boneTransform.transform.GetComponentsInChildren <Transform>(); var childrenIndices = new List <int>(childrenTransforms.Length); foreach (var childTransform in childrenTransforms) { var boneIndex = Array.IndexOf(allTransforms, childTransform); Debug.Assert(boneIndex > 0, "Index can't be less or equal to 0"); childrenIndices.Add(boneIndex - 1); } m_BoneChildrenIndices.Add(childrenIndices); } // Create job. var job = new MixerJob() { handles = m_Handles, boneWeights = m_BoneWeights, weight = 1.0f }; // Create graph with custom mixer. m_Graph = PlayableGraph.Create("CustomMixer"); m_CustomMixerPlayable = AnimationScriptPlayable.Create(m_Graph, job); m_CustomMixerPlayable.SetProcessInputs(false); m_CustomMixerPlayable.AddInput(AnimationClipPlayable.Create(m_Graph, idleClip), 0, 1.0f); m_CustomMixerPlayable.AddInput(AnimationClipPlayable.Create(m_Graph, romClip), 0, 1.0f); var output = AnimationPlayableOutput.Create(m_Graph, "output", animator); output.SetSourcePlayable(m_CustomMixerPlayable); m_Graph.Play(); }
// Start is called before the first frame update void Start() { effector = SampleUtility.CreateEffector("Effector_" + target.name, target.position, target.rotation); }
public static void DrawPackageEditor(UnityPathSelectionInfo selection, PackageJsonFileStream packageTarget, PackageBuildInformation package) { string path = packageTarget.GetAbsolutePath(); GitLinkOnDisk gitLinked = packageTarget.GetLinkedGit(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Create package.json")) { LoadSamplesFromDirectoryToPackage(selection, ref package); string json = PackageBuilder.GetPackageAsJson(package); packageTarget.Set(json, true); AssetDatabase.Refresh(); } if (GUILayout.Button("Create Files & Folders")) { PackageBuilder.CreateUnityPackage(packageTarget.GetPackageProjectRoot(), package); AssetDatabase.Refresh(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (string.IsNullOrEmpty(package.m_projectName)) { package.m_projectName = UnityPaths.AlphaNumeric(Application.productName); } package.m_projectName = (GUILayout.TextField("" + package.m_projectName)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (string.IsNullOrEmpty(package.m_projectAlphNumId)) { // package.m_projectAlphNumId = UnityPaths.AlphaNumeric(Application.productName, true); package.m_projectAlphNumId = selection.GetSelectName(true); } if (string.IsNullOrEmpty(package.m_company)) { package.m_company = UnityPaths.AlphaNumeric(Application.companyName); } package.m_country = UnityPaths.AlphaNumeric(GUILayout.TextField("" + package.m_country)); GUILayout.Label(".", GUILayout.Width(5)); package.m_company = UnityPaths.AlphaNumeric(GUILayout.TextField("" + package.m_company)); GUILayout.Label(".", GUILayout.Width(5)); package.m_projectAlphNumId = UnityPaths.AlphaNumeric(GUILayout.TextField("" + package.m_projectAlphNumId)); GUILayout.EndHorizontal(); GUILayout.Label("Namespace ID: " + package.GetProjectNamespaceId()); GUILayout.Label("Description"); package.m_description = GUILayout.TextArea(package.m_description, GUILayout.MinHeight(100)); GUILayout.BeginHorizontal(); GUILayout.Label("Tags:", GUILayout.MaxWidth(60)); package.m_keywords = GUILayout.TextField(string.Join(",", package.m_keywords)).Split(','); GUILayout.EndHorizontal(); GUILayout.Label("Author"); GUILayout.BeginHorizontal(); GUILayout.Label("Name: ", GUILayout.MaxWidth(60)); package.m_author.m_name = GUILayout.TextField(package.m_author.m_name); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Mail: ", GUILayout.MaxWidth(60)); package.m_author.m_mail = GUILayout.TextField(package.m_author.m_mail); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Url: ", GUILayout.MaxWidth(60)); package.m_author.m_url = GUILayout.TextField(package.m_author.m_url); GUILayout.EndHorizontal(); GUILayout.Label("Repository Info"); GUILayout.BeginHorizontal(); GUILayout.Label("Git Url: ", GUILayout.MaxWidth(60)); package.m_repositoryLink.m_url = GUILayout.TextField(gitLinked.GetUrl()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Revision: ", GUILayout.MaxWidth(60)); package.m_repositoryLink.m_revision = GUILayout.TextField(gitLinked.GetLastRevision()); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.Label("Direct dependence"); DrawEditableDependency(ref package.m_otherPackageDependency); GUILayout.Space(10); GUILayout.Label("Relative dependence"); DrawEditableDependency(ref package.m_otherPackageRelation); SampleDirectoryStream sample = SampleUtility.GetSampleFolder(selection); SampleEditor.DrawInfoAboutInterface(sample); DocumentationDirectoryStream documentation = DocumentationUtility.GetDocumentFolder(selection); DocumentationEditor.DrawInfoAboutInterface(documentation); }