Unity3D的IEnumerator用不了

win8.1 Unity2017.1.1f1 IEnumerator提示不存在图片说明

2个回答

using System.Collections;

协程脚本所挂载的物体,必须是激活状态

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
求教,Unity3D 如何 截屏高于分辨率 的 texture

比如用unity3D导出的应用跑4K分辨率,想截取左下4分之一屏的 保存一张 texture,分辨率也为4K,有没有大神知道?? 使用ScreenCapture.CaptureScreenshot() 虽然能整体放大数倍,但是无法设置具体的截图范围和大小。 类似以下方法可截取自己设定的位置和大小,但是大小无法大于当前应用运行 的分辨率。 ``` IEnumerator SavePhoto(Rect rect,string name) { yield return new WaitForEndOfFrame(); Texture2D t = new Texture2D(rect.width, rect.height); t.ReadPixels(new Rect(0, 0, rect.width, rect.height), 0, 0, false); //距X左的距离 距Y屏上的距离 // t.ReadPixels(rect, 0, 0, false); t.Apply(); byte[] byts = t.EncodeToJPG(100); File.WriteAllBytes(path_Save + name + ".jpg", byts); } ```

关于unity3d与java客户端通信传图片的问题

<p>最近项目中用到了unity,需要在unity中截图,并通过webservices将截图信息传递到java服务器端上。但是在java服务器端上出现了问题,我查了资料不知道如何解决,求指点!!</p> <p> </p> <p>这个是我在unity中写的截取图像的代码,图片信息需要通过WWWFORM上传到java服务器端上</p> <pre name="code" class="c#">public byte[] shot() { int width = Screen.width; int height = Screen.height; Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false); byte[] bytes = tex.EncodeToPNG(); return bytes; } public void getScreenshotByUrl(string data) { StartCoroutine(GetScreenshot(data)); } public IEnumerator GetScreenshot(string data) { byte[] result = shot(); IDictionary jsonDic = (IDictionary)Json.Deserialize(data); string normalUrl = (string)jsonDic["normalUrl"]; string time = string.Format("{0:yyyyMMddHHmmss}", DateTime.Now); //创建一个Web表单 WWWForm form = new WWWForm(); form.AddField("arg0", time); form.AddBinaryData("arg1", result); WWW www = new WWW(normalUrl.ToString(), form); yield return www; if (www.error != null) print(www.error); else print("Finished Uploading Screenshot"); }</pre> <p> 这个是在JAVA中的服务器端的webservices代码</p> <pre name="code" class="java"> @Override public int insertPic(String name,byte[] content) throws Exception { System.out.println(content); System.out.println(name); return (Integer) null; }</pre> <p> 这个是后台报的错误</p> <pre name="code" class="java">2012-10-17 10:13:05 org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging 警告: Interceptor for {http://web.webservice.firems.suresource.com/}LocationWebserviceImplService has thrown exception, unwinding now org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader. at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:237) at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:60) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:123) at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154) at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:128) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:108) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:662) Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,1] Message: Content is not allowed in prolog. at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:594) at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.nextTag(XMLStreamReaderImpl.java:1235) at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:138) ... 27 more</pre>

Unity3D 实时解析XML时报错

获取网络时间: IEnumerator GetTime() { WWW www = new WWW(timeURL); while (!www.isDone) { yield return www; Debug.Log("Doneeeeeeeeeeeeee" + www.text); ParseXml(www); } }` 后得到:` <?xml version="1.0" encoding="GB2312" ?> - <ntsc> - <time> <year>2011</year> <month>7</month> <day>10</day> <Weekday /> <hour>19</hour> <minite>45</minite> <second>37</second> <Millisecond /> </time> </ntsc>` 然后解析时报错: public void ParseXml(WWW www) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(www.text); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodeList = root.SelectNodes("/ntsc/time"); foreach (XmlElement xe in nodeList) { foreach (XmlElement x1 in xe.ChildNodes) { if (x1.Name == "year") { Debug.LogError("x1.InnerText" + x1.InnerText); } } } } 报错语句:` xmlDoc.Load(www.text); 请问如何解决,谢谢!`

Unity3D实现倒计时功能时报错NullReferenceException

IEnumerator CountDown() { while (!isCode) { yield return new WaitForSeconds(5.0f); isCode = true; } Debug.Log("timer=" + timer); } private MonoBehaviour monoBehaviour = new MonoBehaviour(); monoBehaviour.StartCoroutine(CountDown());//报错 用的类是public class UIBind : TTUIPage,没有继承MonoBehaviour, 有什么办法能在这个类中实现倒计时功能呢?

将带有空格的Unity3d字符串存储到MYSQL中的VARCHAR字段中

<div class="post-text" itemprop="text"> <p>I'm working on something with Unity3d MySQL Db. I am passing values through <code>$_GET</code> PHP method but I'm having trouble with strings with white spaces when I store them into the assigned tables.</p> <p>Let's say I have an InputField which gets the string I need. Then, I pass the string through the <code>$_GET</code> method, like this:</p> <pre><code>public InputField myInput; public string a; void StoreData() { a = myInput.text; StartCoroutine(store(a)); } IEnumerator store(string str) { WWW connection = new WWW("http://localhost/route/store_company.php?name=" + str); yield return(connection); } </code></pre> <p>So, after connecting to the DB, in the php file I have:</p> <pre><code>$name = $_GET['name']; $query = "INSERT INTO company(id, name) VALUES (NULL, '$name')"; $get_query = mysqli_query($connection, $query); echo '101'; </code></pre> <p>If I type <em>"Example"</em> in the InputField, the VARCHAR column called name will have "Example". But if I type <em>"This is an example",</em> the VARCHAR column just stores the first word ("This") missing the rest of the sentence.</p> <p>I've sat the VARCHAR to 70 (Length). Pretty new using MySQL. ¿How I capture the whole sentence and why don't work if I am passing a string variable?</p> </div>

PDO搜索查询帮助! [unity3D]

<div class="post-text" itemprop="text"> <p>PHP dispdb.php</p> <pre><code>&lt;?php // Configuration $hostname = '1(Ignore this)'; $username = '1(Ignore this)'; $password = '1(Ignore this)'; $database = '1(Ignore this)'; $secretKey = "1(Ignore this)"; try { $dbh = new PDO('mysql:host='. $hostname .';dbname='. $database, $username, $password); } catch(PDOException $e) { echo '&lt;h1&gt;An error has occurred.&lt;/h1&gt;&lt;pre&gt;', $e-&gt;getMessage() ,'&lt;/pre&gt;'; } $realHash = md5($_GET['search'] . $secretKey); if($realHash == $hash){ $sth = $dbh-&gt;query('SELECT * FROM `oidevstool` WHERE `id` =:search ORDER BY `id`'); $sth-&gt;setFetchMode(PDO::FETCH_ASSOC); $result = $sth-&gt;fetchAll(); if(count($result) &gt; 0) { foreach($result as $r) { echo $r['id'] . "/" . $r['title'] . "/" . $r['priority'] . "/" . $r['deadline'] . "/" . $r['comment']; } } } ?&gt; </code></pre> <p>database.cs</p> <pre><code>using UnityEngine; using System.Collections; public class database : MonoBehaviour { private string secretKey = "1(Don't mid this)"; // Edit this value and make sure it's the same as the one stored on the server public string addScoreURL = "1(Don't mid this)"; //be sure to add a ? to your url public string highscoreURL = "http://example.com/dispdb.php?"; public string dataRetrieved; public string search; public string Md5Sum(string strToEncrypt) { System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding(); byte[] bytes = ue.GetBytes(strToEncrypt); // encrypt bytes System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] hashBytes = md5.ComputeHash(bytes); // Convert the encrypted bytes back to a string (base 16) string hashString = ""; for (int i = 0; i &lt; hashBytes.Length; i++) { hashString += System.Convert.ToString(hashBytes[i], 16).PadLeft(2, '0'); } return hashString.PadLeft(32, '0'); } // Get the scores from the MySQL DB to display in a GUIText. // remember to use StartCoroutine when calling this function! IEnumerator GetScores() { string hash = Md5Sum(search + secretKey); string post_url = highscoreURL + "search=" + search + "&amp;hash=" + hash; WWW hs_post = new WWW(post_url); WWW hs_get = new WWW(highscoreURL); yield return hs_get; if (hs_get.error != null) { print("There was an error getting the high score: " + hs_get.error); } else { dataRetrieved = hs_get.text; } } void OnGUI() { GUI.Box(new Rect(0, 0, 800, 800), dataRetrieved); search = GUI.TextField(new Rect(805, 0, 200, 30), search); if(GUI.Button(new Rect(805, 35, 200, 30), "Search")) { StartCoroutine(GetScores()); } } } </code></pre> <p>i've looking ways to fix but i couldn't find any help for some reason this doesn't work whenever i pressed searched on Unity3D it didn't even show the "success", eventhough i made when hash are correct get data</p> <p>any chance of someone going to help me? that't will be very appreciated</p> <p>Thankyou. Best Regards</p> </div>

UnityWebRequest不发送POST数据

<div class="post-text" itemprop="text"> <p>When Unity sends the POST request it doesn't pass the POST data, so the server returns an error (it gets the server response). I've seen that several people had a similar issue and it got fixed by adding <code>www.chunkedTransfer = false;</code>, however, that doesn't work for me.</p> <p>I've also seen that some people use <code>WWWForm</code> instead of <code>IMultipartFormSection</code>, but I haven't tried it because it is deprecated.</p> <p>I'm using PHP, but I've also tried it with Perl and it didn't work either. When I manually send a POST request everything works normally, so it seems the issue is in Unity. I'm new to Unity, so any help would be appreciated. I'm using the current latest version, 2018.2.18f1 Personal.</p> <p>My code is pretty much the same as the <a href="https://docs.unity3d.com/Manual/UnityWebRequest-SendingForm.html" rel="nofollow noreferrer">official Unity documentation for sending POST request</a>, but apparently it doesn't work. Here is my code:</p> <p>C#:</p> <pre><code>public void Click() { StartCoroutine(PostRequest("http://127.0.0.1/test.php", "help")); } IEnumerator PostRequest(string url, string data) { List&lt;IMultipartFormSection&gt; formData = new List&lt;IMultipartFormSection&gt;(); formData.Add(new MultipartFormDataSection("data=" + data)); UnityWebRequest www = UnityWebRequest.Post(url, formData); www.chunkedTransfer = false; yield return www.SendWebRequest(); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { Debug.Log(www.downloadHandler.text); } } </code></pre> <p>PHP:</p> <pre><code>&lt;?php echo "Server received: " . $_POST["data"]; ?&gt; </code></pre> </div>

从Unity写入服务器上的Text文件

<div class="post-text" itemprop="text"> <p>Hi I have been making an app in Unity and I have been trying to add code that will log User actions i.e. they have made a certain game object appear. What I am trying to do is write to a .txt file stored on a server I have the following code which is based on:</p> <pre><code>http://answers.unity3d.com/questions/984290/upload-txt-file-to-server-using-php.html </code></pre> <p>and they suggest it works, for me it is not writing anything to the file.</p> <p>Here is my PHP code (SaveData.php):</p> <pre><code>&lt;?php $Action = $_GET["action"]; $Date = date('Y/m/d H:i:s'); $myFile = "TestingData.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); fwrite($fh,$Action . "," . $Date . " "); fclose($fh); ?&gt; </code></pre> <p>And here is the C# (SaveData.cs) I am attaching to the game objects I change the Action value in the inspector window:</p> <pre><code>using UnityEngine; using System.Collections; public class SaveData : MonoBehaviour { public string postDataURL = "http://arinstructionman.byethost7.com/SaveData.php?"; //add a ? to your url public string Action; void Start() { StartCoroutine(PostData(Action)); } IEnumerator PostData(string action) { string post_url = postDataURL + "action=" + WWW.EscapeURL(action); WWW data_post = new WWW(post_url); yield return data_post; if (data_post.error != null) { print("There was an error saving data: " + data_post.error); } } } </code></pre> <p>If I copy the post_url value and run it in the browser it seems to work fine, can anyone advise what I am doing wrong?</p> <p>post_url output:</p> <pre><code>http://arinstructionman.byethost7.com/SaveData.php?action=Plane+Visible </code></pre> <p>Any help is much appreciated.</p> </div>

Unity将图像上载到服务器,但Codeigniter不起作用

<div class="post-text" itemprop="text"> <p>I want to upload an image jpg to my server. I have try but it didn't work.</p> <p>I don't what cause the upload failed.</p> <p>Below the detail code.</p> <p><strong>Unity C#</strong></p> <pre><code>public void TakePicture(int maxSize) { if (NativeCamera.IsCameraBusy()) { Debug.Log("Camera Busy"); return; } else { NativeCamera.Permission permission = NativeCamera.TakePicture((path) =&gt; { Debug.Log("Image path: " + path); if (path != null) { // Create a Texture2D from the captured image Texture2D texture = NativeCamera.LoadImageAtPath(path, maxSize); //snap.SetPixels(tex.GetPixels()); byte[] bytes = File.ReadAllBytes(path); Debug.Log("Bytes:" + bytes); Destroy(texture); StartCoroutine(upload_ocr_image(bytes)); if (texture == null) { Debug.Log("Couldn't load texture from " + path); return; } // Assign texture to a temporary quad and destroy it after 5 seconds GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad); quad.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 2.5f; quad.transform.forward = Camera.main.transform.forward; quad.transform.localScale = new Vector3(1f, texture.height / (float)texture.width, 1f); Material material = quad.GetComponent&lt;Renderer&gt;().material; if (!material.shader.isSupported) // happens when Standard shader is not included in the build material.shader = Shader.Find("Legacy Shaders/Diffuse"); material.mainTexture = texture; Destroy(quad, 5f); // If a procedural texture is not destroyed manually, // it will only be freed after a scene change Destroy(texture, 5f); } }, maxSize); Debug.Log("Permission result: " + permission); } } IEnumerator upload_ocr_image(byte[] bytes) { // UtilityScript.GetComponent&lt;utility&gt;().Sand_Clock_Loading(true); // yield return new WaitForSeconds(2.5f); WWWForm formDate = new WWWForm(); formDate.AddField("frameCount", Time.frameCount.ToString()); formDate.AddBinaryData("ocr_image", bytes, "ocr.jpg", "image/jpg"); formDate.AddField("phone_code", "+61"); formDate.AddField("phone_number", "434599859"); using (UnityWebRequest www = UnityWebRequest.Post(web_url.url_upload_ocr_image, formDate)) { yield return www.Send(); //UtilityScript.GetComponent&lt;utility&gt;().Sand_Clock_Loading(false); if (www.isNetworkError) { Debug.Log(www.error); // UtilityScript.GetComponent&lt;utility&gt;().MessageBox_Check_Connection(); } else { Debug.Log(www.downloadHandler.text); } } } </code></pre> <p><strong>And this the code in server codeigniter php.</strong></p> <pre><code>function upload_ocr_image() { $phone_code = $this-&gt;input-&gt;post('phone_code', true); $phone_number = $this-&gt;input-&gt;post('phone_number', true); $allowedType = array(IMAGETYPE_GIF,IMAGETYPE_JPEG,IMAGETYPE_PNG); $imgType = exif_imagetype($_FILES['ocr_image']['tmp_name']); if(!in_array($imgType,$allowedType)) { echo "Images Type Error. Images Type Only : GIF , JPEG, PNG"; exit; } else { //upload original size front end slider $config['upload_path'] = './assets/ocr_image/'; $config['allowed_types'] = 'gif|jpg|png|jpeg'; $config['file_name'] = $phone_code.$phone_number; $config['overwrite'] = FALSE; $config['max_size'] = '8096'; $config['max_width'] = '6000'; $config['max_height'] = '6000'; $this-&gt;load-&gt;library('upload', $config); if(!$this-&gt;upload-&gt;do_upload("ocr_image")) { echo "Maximum File Size Only 2 Mb Or Max Width = 2000 , Height = 2000"; exit; } else { $img_data = $this-&gt;upload-&gt;data(); // Create Thumbnail /* $magicianObj = new imageLib("assets/ocr_image/".$img_data["file_name"].$phone_code.$phone_number); $magicianObj -&gt; resizeImage(80, 80, 0, true); $magicianObj -&gt; saveImage("assets/admin/img/photos/".$img_data["raw_name"]."_thumb".$img_data["file_ext"], 100); $next_id = $next_id.$img_data["file_ext"]; $thumb_name = $img_data["raw_name"]."_thumb".$img_data["file_ext"]; $data = array("photo_name"=&gt;$next_id, "thumb_photo_name"=&gt;$thumb_name, "create_date"=&gt;date("Y-m-d H:i:s")); $this-&gt;db-&gt;insert("gallery_tbl",$data); */ } } } </code></pre> <p><em>No error found. But it always failed.</em></p> <p><strong>This line of code in codeigniter PHP :</strong> </p> <blockquote> <p>if(!$this-&gt;upload-&gt;do_upload("ocr_image"))</p> </blockquote> <p>Always return <strong>true</strong>.</p> <p>How it work ?, How to upload the picture with proper way ?</p> <p><strong>Edited :</strong></p> <p>I use an asset native camera android and ios from unity to take a picture from camera.</p> <p>Thank You</p> </div>

使用C#调用php脚本(Unity)

<div class="post-text" itemprop="text"> <p>I'm fairly new to both Unity and PHP, and I am currently working on a project where I can parse data from a MySQL database to Unity, using PHP.</p> <p>I initially wanted to try and enable a method where the user can perhaps change the php script and enable it to choose a different table of data, however I was advised that it may be safer to list all variables within the php script and call it from Unity accordingly;</p> <p>Display.php</p> <pre><code>$table = mysql_real_escape_string($_GET['table'], $db); if ($table == "shoes") { $query = "SELECT * FROM `shoes` ORDER by `price` ASC LIMIT 10"; elseif ($table == "sneakers") { $query = "SELECT * FROM `sneakers` ORDER by `price` ASC LIMIT 10"; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); $num_results = mysql_num_rows($result); for($i = 0; $i &lt; $num_results; $i++) { $row = mysql_fetch_array($result); echo $row['shopname'] . "\t" . $row['price'] . " "; } </code></pre> <p>I'm having trouble calling the php and choosing the table that I want to select, I am pretty new to this, so I apologise if this seems completely incompetent to you guys.</p> <p>Here is the my Unity Script;</p> <p>HSController.cs</p> <pre><code>void Start() { StartCoroutine(GetScores()); } // remember to use StartCoroutine when calling this function! IEnumerator PostScores(string name, int score) { string hash = Md5Sum(name + score + secretKey); string post_url = addScoreURL + "name=" + WWW.EscapeURL(name) + "&amp;score=" + score + "&amp;hash=" + hash; WWW hs_post = new WWW(post_url); yield return hs_post; // Wait until the download is done if (hs_post.error != null) { print("There was an error posting the high score: " + hs_post.error); } } IEnumerator GetScores() { gameObject.guiText.text = "Loading..."; WWW hs_get = new WWW(highscoreURL); yield return hs_get; if (hs_get.error != null) { print("There was an error getting the high score: " + hs_get.error); } else { gameObject.guiText.text = hs_get.text; // this is a GUIText that will display the scores in game. } } </code></pre> <p>Any help or a point in the right direction would be great!</p> <p>Kind Regards</p> </div>

Unity c#POST到PHP无法正常工作

<div class="post-text" itemprop="text"> <p>I'm having a really annoying problem with php. With c# I send variables to php, and I want php to save it into my database. But the <code>$_POST</code> in php is empty. In Unity I did a <code>Debug.Log</code> of the variables I am sending to php right before it sends to see if it works, and the variables are there. BUT in php when I echo the <code>$_POST</code>, it returns nothing, it's empty and in the database it adds emptiness.</p> <p><strong>Update:</strong> I added an if statement on the php code to see if the post variables are empty, say, it's empty, if they are not empty, update them in the database. BUT it keeps saying the variables are empty. I need to finish this project in 3 days and this is the only problem that I have to fix and I'm done, please help.</p> <p>c#:</p> <pre><code>public IEnumerator replaceData(string toggle1Post, string toggle2Post, string toggle3Post, string toggle4Post, string toggle5Post, string toggle6Post) { WWWForm form = new WWWForm(); form.AddField("toggle1Post", toggle1Post); form.AddField("toggle2Post", toggle2Post); form.AddField("toggle3Post", toggle3Post); form.AddField("toggle4Post", toggle4Post); form.AddField("toggle5Post", toggle5Post); form.AddField("toggle6Post", toggle6Post); WWW www = new WWW(parkingURL, form); yield return www; Debug.Log(www.text); } </code></pre> <p>php:</p> <pre><code>//Make the connection_aborted $conn = new mysqli($server_name, $server_username, $server_password, $dbName); //Check connection_aborted if (!$conn) { die("Connection Failed. ". mysqli_connect_error()); } else { //echo("Connection Success" . "&lt;br&gt;"); } $parkingName1 = "Bus Gate"; $toggle1Post = $_POST['toggle1Post']; $parkingName2 = "Pepsi Gate"; $toggle2Post = $_POST['toggle2Post']; $parkingName3 = "Watson"; $toggle3Post = $_POST['toggle3Post']; $parkingName4 = "PVA"; $toggle4Post = $_POST['toggle4Post']; $parkingName5 = "Gardens"; $toggle5Post = $_POST['toggle5Post']; $parkingName6 = "Omar Mohsen"; $toggle6Post = $_POST['toggle6Post']; if ($toggle1Post != "" || $toggle2Post != "" || $toggle3Post != "" || $toggle4Post != "" || $toggle5Post != "" || $toggle5Post != "") { $sql1 = "UPDATE parking SET Toggle = '$toggle1Post' WHERE gateName = '$parkingName1'"; if (mysqli_query($conn, $sql1)) echo " Updated " . $toggle1Post; else echo "notUpdated: " . mysqli_error($conn); $sql2 = "UPDATE parking SET Toggle = '$toggle2Post' WHERE gateName = '$parkingName2'"; if (mysqli_query($conn, $sql2)) echo " Updated " . $toggle2Post; else echo "notUpdated: " . mysqli_error($conn); $sql3 = "UPDATE parking SET Toggle = '$toggle3Post' WHERE gateName = '$parkingName3'"; if (mysqli_query($conn, $sql3)) echo " Updated " . $toggle3Post; else echo "notUpdated: " . mysqli_error($conn); $sql4 = "UPDATE parking SET Toggle = '$toggle4Post' WHERE gateName = '$parkingName4'"; if (mysqli_query($conn, $sql4)) echo " Updated " . $toggle4Post; else echo "notUpdated: " . mysqli_error($conn); $sql5 = "UPDATE parking SET Toggle = '$toggle5Post' WHERE gateName = '$parkingName5'"; if (mysqli_query($conn, $sql5)) echo " Updated " . $toggle5Post; else echo "notUpdated: " . mysqli_error($conn); $sql6 = "UPDATE parking SET Toggle = '$toggle6Post' WHERE gateName = '$parkingName6'"; if (mysqli_query($conn, $sql6)) echo " Updated " . $toggle6Post; else echo "notUpdated: " . mysqli_error($conn); } else { echo "The variable is empty "; } </code></pre> <p>Update 2: I tried the same code on another computer with unity version 5.4.1f1 and it worked there, on my computer I'm on version 2017.3.0f3 and it does not work.</p> </div>

如何将我的Unity项目连接到ec2实例上的mysql服务器

<div class="post-text" itemprop="text"> <p>I am trying to get data from my MySQL server to my Unity project. I tried to get the data like so:</p> <pre><code>public string awsurl = "ec2-174-129-82-141.compute-1.amazonaws.com/connect_to_server.php"; IEnumerator GetScores() { print("get scores start"); WWW aws_get = new WWW(awsurl); yield return aws_get; print("getscore here"); if (aws_get.error != null) { print("There was an error getting aws: " + aws_get.error); } else { print(aws_get.text); // this is a GUIText that will display the scores in game. } } </code></pre> <p>I have a php script on my server to handle the interaction because I am having trouble using the MySqlConnection library for my unity project. Here is my php script:</p> <pre><code> $address = "localhost" $dbusername = "root"; $dbpassword = "root"; $db_name = "watshoes"; $db_conn = new mysqli($address, $dbusername, $dbpassword, $db_name); if(isset($_POST['username'])) $username = $_POST['username']; if(isset($_POST['user_id'])) $user_id = $_POST['user_id']; if(isset($password)) $password =$_POST['password']; $stmt = $db_conn-&gt;prepare("SELECT image FROM ImageText"); // "s" means the database expects a string $stmt-&gt;bind_param("s", $user_id); if($stmt-&gt;execute()) { /* bind result variables */ $stmt-&gt;bind_result($image); /* fetch value */ $stmt-&gt;fetch(); echo $image; } else { echo "query failed"; } $stmt-&gt;close(); $db_conn-&gt;close(); </code></pre> <p>But every time I run the code I get this error:<code>There was an error getting aws: Failed to connect to ec2-174-129-82-141.compute-1.amazonaws.com port 80: Timed out</code></p> <p>Thanks for looking at the code and please let me know if there is anything else I can do to help.</p> </div>

保护C#和PHP之间的通信(而不是加密数据)

<div class="post-text" itemprop="text"> <p>I'm developing an Android and iOS game, I need to call the php pages to collect and enter data into the database mysql.</p> <p>Sending and reception of data works properly, the problem is that the data sent is not encrypted, but this I can solve it with the ssl certificates, in order to have all the data send encrypted.</p> <p>The other problem is that with some appropriate programs (example: Charles Proxy) you can see the address pointed to my php file, and consequently you can resubmit the packet over and over again.</p> <p>For example:</p> <p>This is my test.php:</p> <pre><code>$code = $_POST['SecretCode']; if($code == "secretcode") { // Connect to DB and increment 'i' value } </code></pre> <p>This is my C# code in Unity3D:</p> <pre><code>public IEnumerator test() { WWWForm form = new WWWForm(); form.AddField("SecretCode", secretcode); WWW www = new WWW("http://sitename.com/test.php", form); yield return www; if(www.text != "") { // Returned value } } </code></pre> <p>Now, if from my game I call the 'test ()' function, the php called check the security code, and if it is right, will increase the variable on the database.</p> <p>While the game sends this request, Charles Proxy can see the request and therefore I can with Charles resend endlessly the request, increasing endlessly the value in the database.</p> <p>To make you understand better I'll show you a picture that sums it all:</p> <p><a href="http://postimg.org/image/x3owvt5il/" rel="nofollow">http://postimg.org/image/x3owvt5il/</a></p> <p>Finally there is a way to make invisible the php file or make it look unknown? Or just do not change the value on the database if someone tries to repeat these requests?</p> </div>

Unity中的WWW返回空字符串

<div class="post-text" itemprop="text"> <p>Its returning an empty string and I can't seem to figure out why, if you visit the page it outputs fine. (<a href="http://lgdev.site.nfoservers.com/getItems.php" rel="nofollow">http://lgdev.site.nfoservers.com/getItems.php</a>). I'm trying to get all the data, separate it by certain characters, then use the code in the game t operate it and sort it into the correct places. But like I said its returning an empty string instead of the data that's show on the webpage I gave above.</p> <p>Game Code:</p> <pre><code> public void loadItems() { WWWForm form = new WWWForm(); WWW w = new WWW("http://lgdev.site.nfoservers.com/getItems.php", form); StartCoroutine(loadItemsFunc(w)); } IEnumerator loadItemsFunc(WWW w) { yield return w; Debug.Log(w.text); string[] tmpdata1 = w.text.Split(char.Parse("=")); foreach(string data in tmpdata1) { string[] tmpinfo = data.Split(char.Parse("~")); GameObject tmpObj = Instantiate(weapon); tmpObj.GetComponent&lt;weapon&gt;().name = tmpinfo[0]; tmpObj.GetComponent&lt;weapon&gt;().vitalisim = int.Parse(tmpinfo[1]); tmpObj.GetComponent&lt;weapon&gt;().defence = int.Parse(tmpinfo[2]); tmpObj.GetComponent&lt;weapon&gt;().strength = int.Parse(tmpinfo[3]); string[] offsetInfo1 = tmpinfo[5].Split(char.Parse(";")); foreach (string off in offsetInfo1) { string[] offset = off.Split(char.Parse(",")); tmpObj.GetComponent&lt;weapon&gt;().offsetsPos.Add(new Vector3(float.Parse(offset[0]), float.Parse(offset[1]), float.Parse(offset[2]))); tmpObj.GetComponent&lt;weapon&gt;().offetsRot.Add(new Vector3(float.Parse(offset[3]), float.Parse(offset[4]), float.Parse(offset[5]))); tmpObj.GetComponent&lt;weapon&gt;().offetsSize.Add(new Vector3(float.Parse(offset[6]), float.Parse(offset[7]), float.Parse(offset[8]))); } string[] typeInfo = tmpinfo[4].Split(char.Parse(",")); if (tmpinfo[1] == "SwordnShield") { tmpObj.GetComponent&lt;weapon&gt;().anim = swordAndShieldAnimSet; } else if (tmpinfo[1] == "TwoHanded") { tmpObj.GetComponent&lt;weapon&gt;().anim = twoHandedAnimSet; } foreach (string prefab in tmpinfo[6].Split(char.Parse(","))) { tmpObj.GetComponent&lt;weapon&gt;().prefabs.Add(prefab); } } } </code></pre> <p>PHP Code:</p> <p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?PHP $con = mysql_connect("localhost","user","passs") or ("Cannot connect!" . mysql_error()); if (!$con) die('Could not connect: ' . mysql_error()); mysql_select_db("lgdev_projectzed" , $con) or die ("could not load the database" . mysql_error()); $query = "SELECT * FROM `equipment`"; $check = mysql_query($query) or die(mysql_error()." ".$query); if($check){ } $numrows = mysql_num_rows($check); $text = ""; while ($row = mysql_fetch_array($check, MYSQL_ASSOC)) { $text = $text."".$row["name"]."~".$row["vitalism"]."~".$row["defence"]."~".$row["strength"]."~".$row["type"]."~".$row["offsets"]."~". $row["prefabs"] ."="; } die($text); ?&gt;</code></pre> </div> </div> </div>

如何在不充斥NIC的情况下监视数据库中的更改

<div class="post-text" itemprop="text"> <p>I have a web server which contains a sql database. There are two "users" to this server/database. One is the actual user where they will submit changes through a UnityWebRequest using HTTP:Post. This will make changes to the database.</p> <p>I have another system that is also in Unity, that needs to be notified, or somehow monitor for whenever a change is made to a specific table in a database. I don't know how to monitor the table for changes without constantly making select calls to the database.</p> <p>What I've tried</p> <p>I have a unity function which calls the webserver through HTTP:Post. The webserver goes into an infinite while loop making calls to the database something like </p> <pre><code>$variable = $_REQUEST['variable_to_monitor']; $stmt = $pdo-&gt;prepare("SELECT variable_to_monitor FROM table_name;") while(true){ $stmt-&gt;execute(); results = $stmt-&gt;fetchAll()[0]; if ($variable != results['variable_to_monitor']){ die(results['variable_to_monitor']); } } </code></pre> <p>This holds up the webserver and is making too many calls to the database. </p> <p>I would like for Unity to be able to make a single call to a web server giving it a given state, the web server will compare said state to database until the database changes, then once the db changes respond to unity with the updated state. I want to be able to do this without making a million SELECT calls to a database per second.</p> <p>Unity Code</p> <pre><code> void Update() { if(hasResponse) { hasResponse = false; StartCoroutine(SendRequest()); } } IEnumerator SendRequest(WWWForm form = null, Action&lt;string&gt; callback = null) { if(null == form) form = new WWWForm(); form.AddField("request", "monitor_variable"); form.AddField("variable_to_monitor", this.variable_to_monitor); UnityWebRequest www = UnityWebRequest.Post(url, form); yield return www.SendWebRequest(); if (www.isNetworkError) { Debug.Log("Network Error"); } else if (www.isHttpError) { Debug.Log("Http Error"); } else { if(null == callback) { Debug.Log(www.downloadHandler.text); } else { if (!www.downloadHandler.text.Contains("New Request Started")) { hasResponse = true; callback(www.downloadHandler.text); } else { Debug.Log(www.downloadHandler.text); } } } } </code></pre> </div>

使用bool.ToString()的$ _POST和WWWForm不起作用

<div class="post-text" itemprop="text"> <p>I have been working on making a custom server (probably won't work but I want to give it a try and work on it as a hobby) but I've already run into a problem! What I have the php scripts outputing the commands as text then getting unity to translate that into the c# commands.</p> <p>Here's the ServerCalls.cs:</p> <pre><code>using UnityEngine; using UnityEngine.UI; using System.Collections; using System; using System.Linq; public class ServerCallsScript : MonoBehaviour { private bool isPlayerInRoom = false; public bool autoConnectToLobby; public bool showLobbyGUI; public float width; public float height; public float x; public float y; public enum logTypeEnum { Developer, Debug, Warning, Error }; public logTypeEnum logType = logTypeEnum.Warning; public string MainServerUrl = "https://network-hlapi-myusername.c9.io/serverMain.php"; private string serverText = ""; void Start() { StartCoroutine(ServerCommands()); } void Update() { } void OnGUI() { if (showLobbyGUI) { if(GUI.Button(new Rect(5,80,115,21), "Create Game")) { } GUI.TextField(new Rect(130, 80, 115, 21), "Game1"); if(GUI.Button(new Rect(5, 110, 115, 21), "Join Game")) { } GUI.TextField(new Rect(130, 110, 115, 21),"Game Name"); } } /// &lt;summary&gt; /// This is called as soon as the player opens the scene /// &lt;/summary&gt; public void OnConnectedToServer() { if (logType == logTypeEnum.Debug || logType == logTypeEnum.Developer) { Debug.Log("Successfully Connected To Server at " + DateTime.Now.ToString("hh:mm:ss")); } } /// &lt;summary&gt; /// Called When Player Connects To Lobby. Automatically called if auto-join lobby is enabled /// &lt;/summary&gt; public void OnConnectedToLobby() { if (logType == logTypeEnum.Debug || logType == logTypeEnum.Developer) { Debug.Log("Connected To Lobby at " + DateTime.Now.ToString("hh:mm:ss")); } } public void ShowLobbyGui() { if (logType == logTypeEnum.Debug || logType == logTypeEnum.Developer) { Debug.Log("Showing Lobby Gui"); } } /// &lt;summary&gt; /// Called when the player joins a game /// &lt;/summary&gt; public void OnPlayerJoinedRoom() { if (logType == logTypeEnum.Debug || logType == logTypeEnum.Developer) { Debug.Log("Player Successfully Joined Room at " + DateTime.Now.ToString("hh:mm:ss")); } } IEnumerator ServerCommands() { Debug.Log("Collecting Info from Server..."); WWWForm Mainform = new WWWForm(); Mainform.AddField("isAutoJoinLobby", autoConnectToLobby.ToString()); Mainform.AddField("isShowingLobbyGui", showLobbyGUI.ToString()); Mainform.AddField("hasPlayerJoinedRoom", isPlayerInRoom.ToString()); WWW mainServer = new WWW(MainServerUrl, Mainform); yield return mainServer; serverText = mainServer.text; string[] serverCommands = serverText.Split(' '); if(mainServer.error != null) { Debug.LogError("We encountered an error! Error:" + mainServer.error); } if (serverCommands.Contains("OnConnectedToServer")) { OnConnectedToServer(); } if (serverCommands.Contains("OnConnectedToLobby")) { Debug.Log("OnConnectedToLobby"); OnConnectedToLobby(); } if (serverCommands.Contains("showLobbyGui")) { ShowLobbyGui(); } if (serverCommands.Contains("OnPlayerJoinedRoom")) { OnPlayerJoinedRoom(); } } } </code></pre> <p>For ServerMain.php:</p> <pre><code>&lt;?php $servername = getenv('IP'); $username = getenv('C9_USER'); $password = "I Wouldn't Tell You That Now"; $database = "server"; $dbport = 3306; // Create connection $db = mysql_connect($servername, $username, $password, $dbport)or die("Cant Connect to server"); mysql_select_db($database) or die("Cant connect to database"); $isAutoConnectToLobby = $_POST['isAutoJoinLobby']; $isShowingLobbyGui = $_POST['isShowingLobbyGui']; $hasPlayerJoinedRoom = $_POST['hasPlayerJoinedRoom']; $ClientClickConnectButton = $_POST['ClientClickConnectButton']; echo "OnConnectedToServer "; if ($isAutoConnectToLobby == true){ echo "OnConnectedToLobby "; } if($isShowingLobbyGui == true){ echo "showLobbyGui "; } if($ClientClickConnectButton == true){ sleep(5); //Just to give some time to complete any in-complete operations echo "onClientClickConnectButton "; } if($hasPlayerJoinedRoom == true){ echo "OnPlayerJoinedRoom "; } ?&gt; </code></pre> <p>The problem is that the ServerMain.php script doesn't seem to listen to any of the WWWForm fields. If you add quotes to the if statements in the php script it just goes through all the if statements but if you don't add quotes it doesn't do any of the if statements, even if the public bools are enabled</p> </div>

Coroutines或Php脚本不适用于移动设备

<div class="post-text" itemprop="text"> <p>Hi this is my first query using stack overflow so lets get to it. i am making an android game that uses database that is on a server of a site i am using phpmyadmin to manage mysql and here is how i retrieve data </p> <pre><code>public class Dataretrieve : MonoBehaviour { WWW sitedata; public string[] users; public static string[] Usernames; public static string[] Emails; public static string[] Passwords; public static string[] Icons; // Use this for initialization public void Start(){ StartCoroutine_Auto(StartGettingData); } public IEnumerator StartGettingData () { Debug.Log ("Starting to get values"); sitedata = new WWW ("mysite/database.php"); yield return sitedata; string sitedatatext = sitedata.text; users = sitedatatext.Split (';'); Usernames=new string[users.Length-1]; Emails=new string[users.Length-1]; Passwords=new string[users.Length-1]; Icons=new string[users.Length-1]; for (int i=0; i&lt;users.Length-1; i++) { Usernames[i]=GetData(users[i],"Username:"); Emails[i]=GetData(users[i],"Email:"); Passwords[i]=GetData(users[i],"Password:"); Icons[i]=GetData(users[i],"Icon:"); } Debug.Log ("All Data Retrieved"); StopCoroutine ("StartGettingData"); } string GetData(string data,string index) { string value = data.Substring (data.IndexOf (index) + index.Length); if (value.Contains ("|")) value = value.Remove (value.IndexOf ("|")); return value; } public void values() { Debug.Log ("Start getting values again"); StartCoroutine_Auto(StartGettingData()); StopCoroutine ("StartGettingData"); Debug.Log ("Values Updated again"); } </code></pre> <p>}</p> <p>The problem is it works fine on unity editor but when i run it on built it doesn't get users data</p> <p>here's php code </p> <p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>$conn=new mysqli($servername,$username,$password,$dbName); if(!$conn) { die("Connection Failled".mysqli_connect_error() ); } $sql="SELECT ID, Email, Password, Username, Icon FROM Login_Variables"; $result = mysqli_query($conn ,$sql); if(mysqli_num_rows($result) &gt; 0) while( $row =mysqli_fetch_assoc($result)) { echo("ID:".$row['ID']."|Email:".$row['Email']."|Password:".$row['Password']."|Username:".$row['Username']."|Icon:".$row['Icon'].";"); }</code></pre> </div> </div> </div>

too long

<div class="post-text" itemprop="text"> <p>I have data from <strong>SQL database</strong> that contains <strong>xml text</strong> which are being <em>echoed</em> with <strong>php script</strong></p> <p>For example this: <br> <em>No:1|TestName:MachineAlfonso|TestParameter:&lt; asdf/&gt;|TestConnection:1234;</em></p> <p>This data is later being parsed to <strong>Unity</strong> for later uses. <br> however when i try to print it in unity, It somehow converting the <strong>&lt;</strong> to <strong>&amp;lt ;</strong> and the <strong>&gt;</strong> to <strong>&amp;gt ;</strong></p> <p>The full output become <br> <em>No:1|TestName:MachineAlfonso|TestParameter:&amp;lt ; asdf/&amp;gt ;|TestConnection:1234;</em></p> <p>Is there any function to print the output to become a human readable sign not as html code? because those two signs( &lt; and &gt;) are just some than many other html simple that i want to convert.</p> <p>this is the C# script i use to print the echoed data</p> <pre><code> public IEnumerator RefreshData() { //load the data //dataLoader is the link of the echoed php data WWW InventoryDatabase = new WWW(dataLoaderURL); //wait until its done dowloading yield return InventoryDatabase; string abc = InventoryDatabase.text; Debug.Log("text is: " + abc); } </code></pre> </div>

一段时间后,XAMPP变得非常缓慢

<div class="post-text" itemprop="text"> <p>Does anyone ever encounter the MYSQL in XAMPP being super slow after sometime?</p> <p>I have a unity application that asking a string to be downloaded with this php script.</p> <pre><code>&lt;?php include 'Config.php'; // Just a normal mysqli connection setup //the post from Unity. $var_uniqueID = $_POST['uniqueID_Post']; $conn = OpenCon(); // open connection //create a query $sql = "SELECT var_name, var_value FROM variable_current_values WHERE uniqueID = '".$var_uniqueID."' "; $result = mysqli_query($conn, $sql); if( mysqli_num_rows($result) &gt; 0) { //show data for each row while($row = mysqli_fetch_assoc($result)) { echo "".$row['var_name'] . "|".$row['var_value'] . ""; } } CloseCon($conn); // close the connection ?&gt; </code></pre> <p>This PHP script is being called with c# script of UnityWebRequest <br></p> <pre><code> //www variable private UnityWebRequest unityWebRequest; void Update () { if (unityWebRequest == null) { //fetch The data Widget StartCoroutine(RealDataFetchWhere(this.name)); } } private IEnumerator RealDataFetchWhere(string _uniqueIDPost) { //gives the unique key WWWForm fetchingForm = new WWWForm(); fetchingForm.AddField("uniqueID_Post", _uniqueIDPost); //load and wait until the data is downloaded unityWebRequest = UnityWebRequest.Post(**thePHPLink**, fetchingForm); yield return unityWebRequest.SendWebRequest(); string data = unityWebRequest.downloadHandler.text; print("the Data is : " + data); } </code></pre> <p>At first everything seems to be fine. Data is downloaded perfectly(almost in realtime speed). <br><br> However after like more than 10 minutes, the XAMPP mySQL starting to slow down considerably. <br>I try to modified the data manually in XAMPP and it takes about 5 - 8 seconds until the <em>"row is affected"</em> <br>If i leave them longer without closing my unity program, XAMPP start to freeze and disconnected. <br> <br>Does anyone know the solutions to counter this problem ? </p> </div>

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

Linux面试题(2020最新版)

文章目录Linux 概述什么是LinuxUnix和Linux有什么区别?什么是 Linux 内核?Linux的基本组件是什么?Linux 的体系结构BASH和DOS之间的基本区别是什么?Linux 开机启动过程?Linux系统缺省的运行级别?Linux 使用的进程间通信方式?Linux 有哪些系统日志文件?Linux系统安装多个桌面环境有帮助吗?什么是交换空间?什么是root帐户什么是LILO?什...

Linux命令学习神器!命令看不懂直接给你解释!

大家都知道,Linux 系统有非常多的命令,而且每个命令又有非常多的用法,想要全部记住所有命令的所有用法,恐怕是一件不可能完成的任务。 一般情况下,我们学习一个命令时,要么直接百度去搜索它的用法,要么就直接用 man 命令去查看守冗长的帮助手册。这两个都可以实现我们的目标,但有没有更简便的方式呢? 答案是必须有的!今天给大家推荐一款有趣而实用学习神器 — kmdr,让你解锁 Linux 学习新姿势...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

史上最全的 python 基础知识汇总篇,没有比这再全面的了,建议收藏

网友们有福了,小编终于把基础篇的内容全部涉略了一遍,这是一篇关于基础知识的汇总的文章,请朋友们收下,不用客气,不过文章篇幅肯能会有点长,耐心阅读吧爬虫(七十)多进程multiproces...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

85后蒋凡:28岁实现财务自由、34岁成为阿里万亿电商帝国双掌门,他的人生底层逻辑是什么?...

蒋凡是何许人也? 2017年12月27日,在入职4年时间里,蒋凡开挂般坐上了淘宝总裁位置。 为此,时任阿里CEO张勇在任命书中力赞: 蒋凡加入阿里,始终保持创业者的冲劲,有敏锐的...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

新一代神器STM32CubeMonitor介绍、下载、安装和使用教程

关注、星标公众号,不错过精彩内容作者:黄工公众号:strongerHuang最近ST官网悄悄新上线了一款比较强大的工具:STM32CubeMonitor V1.0.0。经过我研究和使用之...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

大学一路走来,学习互联网全靠这几个网站,最终拿下了一把offer

大佬原来都是这样炼成的

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

什么时候跳槽,为什么离职,你想好了么?

都是出来打工的,多为自己着想

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你期望月薪4万,出门右拐,不送,这几个点,你也就是个初级的水平

先来看几个问题通过注解的方式注入依赖对象,介绍一下你知道的几种方式@Autowired和@Resource有何区别说一下@Autowired查找候选者的...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

立即提问
相关内容推荐