{"id":1369,"date":"2015-06-11T02:37:31","date_gmt":"2015-06-10T18:37:31","guid":{"rendered":"http:\/\/www.clonefactor.com\/wordpress\/?p=1369"},"modified":"2015-06-11T02:38:35","modified_gmt":"2015-06-10T18:38:35","slug":"switch-case-%e8%b7%9f-if-else","status":"publish","type":"post","link":"https:\/\/www.clonefactor.com\/wordpress\/program\/c\/1369\/","title":{"rendered":"Switch case \u8ddf If-Else"},"content":{"rendered":"<p>\u512a\u5316\u81ea\u5df1\u5167\u78bc\u6642\u767c\u73fe\u7684\u5947\u602a\u73fe\u50cf&#8230;.<br \/>\nCameraBot \u5c08\u6848\u88e1\u982d\u70ba\u4e86\u65b9\u4fbf\u7d93\u5e38\u4f7f\u7528 Switch-case, \u5176\u7d50\u679c\u7adf\u7136\u6bd4 If-else \u66f4\u5feb<\/p>\n<p>\u4ee5\u9019\u6bb5\u70ba\u4f8b:<br \/>\n(If-Else \u8ddf Switch-case \u8655\u7406\u7d50\u679c\u76f8\u540c&#8230;)<\/p>\n<pre class=\"brush:csharp\">private void UpdateCameraPosition(Preset preset)\r\n{\r\n\tif (ControlPosition == null)\r\n\t\treturn;\r\n\tfloat time = Time.deltaTime * preset.Method.PositionSpeed;\r\n#if UseIfElse\r\n\tControlPosition.position =\r\n\t\t(preset.Method.MoveMethod.Equals(MoveMethod.QuaternionLerp)) ? Vector3.Slerp(ControlPosition.position, preset.Cache.CameraFinalPosition, time) :\r\n\t\t(preset.Method.MoveMethod.Equals(MoveMethod.lerp)) ? Vector3.Lerp(ControlPosition.position, preset.Cache.CameraFinalPosition, time) :\r\n\t\tpreset.Cache.CameraFinalPosition;\r\n#elif UseSwitchCase\r\n\tswitch (preset.Method.MoveMethod)\r\n\t{\r\n\tdefault:\r\n\tcase MoveMethod.Snap:\r\n\t\tControlPosition.position = preset.Cache.CameraFinalPosition;\r\n\t\tbreak;\r\n\tcase MoveMethod.lerp:\r\n\t\tControlPosition.position = Vector3.Lerp(ControlPosition.position, preset.Cache.CameraFinalPosition, time);\r\n\t\tbreak;\r\n\tcase MoveMethod.QuaternionLerp:\r\n\t\tControlPosition.position = Vector3.Slerp(ControlPosition.position, preset.Cache.CameraFinalPosition, time);\r\n\t\tbreak;\r\n\t}\r\n#endif\r\n}<\/pre>\n<div>\u57f7\u884c\u7684\u7d50\u679c.<\/div>\n<div>\n<div>Switch-Case<\/div>\n<div>\n<figure id=\"attachment_1371\" aria-describedby=\"caption-attachment-1371\" style=\"width: 300px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2015\/06\/ScreenShot003.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1371\" src=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2015\/06\/ScreenShot003-300x147.jpg\" alt=\"Switch-case result\" width=\"300\" height=\"147\" srcset=\"https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2015\/06\/ScreenShot003-300x147.jpg 300w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2015\/06\/ScreenShot003.jpg 975w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1371\" class=\"wp-caption-text\">Switch-case result<\/figcaption><\/figure>\n<\/div>\n<\/div>\n<div>If-Else<\/div>\n<div>\n<div>\n<figure id=\"attachment_1370\" aria-describedby=\"caption-attachment-1370\" style=\"width: 300px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2015\/06\/ScreenShot002.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1370\" src=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2015\/06\/ScreenShot002-300x143.jpg\" alt=\"If-Else result\" width=\"300\" height=\"143\" srcset=\"https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2015\/06\/ScreenShot002-300x143.jpg 300w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2015\/06\/ScreenShot002.jpg 975w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1370\" class=\"wp-caption-text\">If-Else result<\/figcaption><\/figure>\n<\/div>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div><\/div>\n<div>\n<div>\u5728\u9019\u5c08\u6848\u88e1\u591a\u4f54\u7528\u7684 120B \u5c31\u662f If-else \u7684\u4f54\u7528\u8cc7\u6e90, \u7576\u7136\u4e0d\u662f\u55ae\u55ae\u4e00\u500b If else, \u662f\u7e3d\u91cf.<\/div>\n<div>\u4e4b\u5f8c\u67e5\u4e00\u4e0b\u8cc7\u6599\u624d\u767c\u73fe\u7d93\u5e38\u88ab\u8001\u624b\u553e\u7f75\u7684 Swtich-case \u539f\u4f86\u5728\u9ad8\u4f7f\u7528\u91cf\u7684\u6642\u5019\u6548\u679c\u975e\u5e38\u597d,<\/div>\n<div>\u9019\u5c08\u6848\u5927\u90e8\u4efd\u8f38\u5165\u904b\u7b97\u662f\u4f7f\u7528 FixUpdate, \u5176\u4ed6\u986f\u793a\u5247\u4f7f\u7528 LateUpdate \u8ddf Update.<\/div>\n<div><\/div>\n<\/div>\n<div>\u5176\u5f8c\u67e5\u627e\u5230\u9019\u90e8\u4efd\u7684\u8a73\u7d30\u8cc7\u6599\u4ee5\u4f5c\u53c3\u8003.<\/div>\n<div>\n<div>\n<h1><span style=\"color: #ffa000; font-size: xx-large;\">Speed Test: Switch vs If-Else-If<\/span><\/h1>\n<\/div>\n<div><a href=\"http:\/\/ref.gamer.com.tw\/redir.php?url=http%3A%2F%2Fwww.blackwasp.co.uk%2FSpeedTestIfElseSwitch.aspx\" target=\"_blank\">http:\/\/www.blackwasp.co.uk\/SpeedTestIfElseSwitch.aspx<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u512a\u5316\u81ea\u5df1\u5167\u78bc\u6642\u767c\u73fe\u7684\u5947\u602a\u73fe\u50cf&#8230;. CameraBot \u5c08\u6848\u88e1\u982d\u70ba\u4e86\u65b9\u4fbf\u7d93\u5e38\u4f7f\u7528 Swit &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,11],"tags":[17,73],"class_list":["post-1369","post","type-post","status-publish","format-standard","hentry","category-c","category-unity3d","tag-camera","tag-code-pattern"],"_links":{"self":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1369"}],"version-history":[{"count":0,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1369\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}