{"id":3458,"date":"2014-12-02T14:58:57","date_gmt":"2014-12-02T11:58:57","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=3458"},"modified":"2014-12-02T15:00:13","modified_gmt":"2014-12-02T12:00:13","slug":"one-liners-simple-pause","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2014\/12\/02\/one-liners-simple-pause\/","title":{"rendered":"One liners: Simple Pause"},"content":{"rendered":"<p>Simple pause script for quick testing:<\/p>\n<p>&#8211; When P key is pressed, Time.timeScale value is toggled between values <strong>0<\/strong> (pause) and <strong>1<\/strong> (default)<\/p>\n<p>How to use:<br \/>\n&#8211; Create new script file (c#)<br \/>\n&#8211; Name it as &#8220;PauseMode&#8221;<br \/>\n&#8211; Copy &amp; paste the contents below (or just take the 1 line inside Update() loop:<\/p>\n<style>.gist table { margin-bottom: 0; }<\/style>\n<div style=\"tab-size: 8\" id=\"gist16736678\" class=\"gist\">\n<div class=\"gist-file\" translate=\"no\" data-color-mode=\"light\" data-light-theme=\"light\">\n<div class=\"gist-data\">\n<div class=\"js-gist-file-update-container js-task-list-container\">\n<div id=\"file-onelinepause-cs\" class=\"file my-2\">\n<div itemprop=\"text\"\n      class=\"Box-body p-0 blob-wrapper data type-c  \"\n      style=\"overflow: auto\" tabindex=\"0\" role=\"region\"\n      aria-label=\"OneLinePause.cs content, created by unitycoder on 08:34AM on December 02, 2014.\"\n    ><\/p>\n<div class=\"js-check-hidden-unicode js-blob-code-container blob-code-content\">\n<p>  <template class=\"js-file-alert-template\"><\/p>\n<div data-view-component=\"true\" class=\"flash flash-warn flash-full d-flex flex-items-center\">\n  <svg aria-hidden=\"true\" data-component=\"Octicon\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n    <span><br \/>\n      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.<br \/>\n      <a class=\"Link--inTextBlock\" href=\"https:\/\/github.co\/hiddenchars\" target=\"_blank\">Learn more about bidirectional Unicode characters<\/a><br \/>\n    <\/span><\/p>\n<div data-view-component=\"true\" class=\"flash-action\">        <a href=\"{{ revealButtonHref }}\" data-view-component=\"true\" class=\"btn-sm btn\">    Show hidden characters<br \/>\n<\/a>\n<\/div>\n<\/div>\n<p><\/template><br \/>\n<template class=\"js-line-alert-template\"><br \/>\n  <span aria-label=\"This line has hidden Unicode characters\" data-view-component=\"true\" class=\"line-alert tooltipped tooltipped-e\"><br \/>\n    <svg aria-hidden=\"true\" data-component=\"Octicon\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n<\/span><\/template><\/p>\n<table data-hpc class=\"highlight tab-size js-file-line-container\" data-tab-size=\"4\" data-paste-markdown-skip data-tagsearch-path=\"OneLinePause.cs\">\n<tr>\n<td id=\"file-onelinepause-cs-L1\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"1\"><\/td>\n<td id=\"file-onelinepause-cs-LC1\" class=\"blob-code blob-code-inner js-file-line\">using UnityEngine;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-onelinepause-cs-L2\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"2\"><\/td>\n<td id=\"file-onelinepause-cs-LC2\" class=\"blob-code blob-code-inner js-file-line\">using System.Collections;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-onelinepause-cs-L3\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"3\"><\/td>\n<td id=\"file-onelinepause-cs-LC3\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-onelinepause-cs-L4\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"4\"><\/td>\n<td id=\"file-onelinepause-cs-LC4\" class=\"blob-code blob-code-inner js-file-line\">public class PauseMode : MonoBehaviour <\/td>\n<\/tr>\n<tr>\n<td id=\"file-onelinepause-cs-L5\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"5\"><\/td>\n<td id=\"file-onelinepause-cs-LC5\" class=\"blob-code blob-code-inner js-file-line\">{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-onelinepause-cs-L6\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"6\"><\/td>\n<td id=\"file-onelinepause-cs-LC6\" class=\"blob-code blob-code-inner js-file-line\">\tvoid Update () <\/td>\n<\/tr>\n<tr>\n<td id=\"file-onelinepause-cs-L7\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"7\"><\/td>\n<td id=\"file-onelinepause-cs-LC7\" class=\"blob-code blob-code-inner js-file-line\">\t{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-onelinepause-cs-L8\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"8\"><\/td>\n<td id=\"file-onelinepause-cs-LC8\" class=\"blob-code blob-code-inner js-file-line\">\t\tif (Input.GetKeyDown (&quot;p&quot;)) Time.timeScale = 1-Time.timeScale;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-onelinepause-cs-L9\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"9\"><\/td>\n<td id=\"file-onelinepause-cs-LC9\" class=\"blob-code blob-code-inner js-file-line\">\t}<\/td>\n<\/tr>\n<tr>\n<td id=\"file-onelinepause-cs-L10\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"10\"><\/td>\n<td id=\"file-onelinepause-cs-LC10\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n<\/tr>\n<\/table>\n<\/div><\/div>\n<\/p><\/div>\n<\/div><\/div>\n<div class=\"gist-meta\">\n        <a href=\"https:\/\/gist.github.com\/unitycoder\/cefa1aa35d51d743f56d\/raw\/5efdae9e56a6f5a13fb046727b1dc66899f5d592\/OneLinePause.cs\" style=\"float:right\" class=\"Link--inTextBlock\">view raw<\/a><br \/>\n        <a href=\"https:\/\/gist.github.com\/unitycoder\/cefa1aa35d51d743f56d#file-onelinepause-cs\" class=\"Link--inTextBlock\"><br \/>\n          OneLinePause.cs<br \/>\n        <\/a><br \/>\n        hosted with &#10084; by <a class=\"Link--inTextBlock\" href=\"https:\/\/github.com\">GitHub<\/a>\n      <\/div>\n<\/p><\/div>\n<\/div>\n<p><strong>Docs:<\/strong><br \/>\n<a title=\"http:\/\/docs.unity3d.com\/ScriptReference\/Time-timeScale.html\" href=\"http:\/\/docs.unity3d.com\/ScriptReference\/Time-timeScale.html\" target=\"_blank\">http:\/\/docs.unity3d.com\/ScriptReference\/Time-timeScale.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Simple pause script for quick testing: &#8211; When P key is pressed, Time.timeScale value is toggled between values 0 (pause) and 1 (default) How to use: &#8211; Create new script file (c#) &#8211; Name it as &#8220;PauseMode&#8221; &#8211; Copy &amp; paste the contents below (or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3459,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[420,3],"tags":[680,189,622,383],"class_list":["post-3458","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-unity3d","tag-pause","tag-script","tag-tips","tag-tutorial"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2014\/12\/time_timescale.jpg?fit=404%2C214&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-TM","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/3458","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=3458"}],"version-history":[{"count":3,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/3458\/revisions"}],"predecessor-version":[{"id":3462,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/3458\/revisions\/3462"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/3459"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=3458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=3458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=3458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}