<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by 陳威寰 on Medium]]></title>
        <description><![CDATA[Stories by 陳威寰 on Medium]]></description>
        <link>https://medium.com/@william09250?source=rss-62c054f703fb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*n27dslhpWm6pQY1i.jpg</url>
            <title>Stories by 陳威寰 on Medium</title>
            <link>https://medium.com/@william09250?source=rss-62c054f703fb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 21:48:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@william09250/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[關於NullReferenceException的問題]]></title>
            <link>https://medium.com/will-unity/%E9%97%9C%E6%96%BCnullreferenceexception%E7%9A%84%E5%95%8F%E9%A1%8C-9e632ee51553?source=rss-62c054f703fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e632ee51553</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[unity3d]]></category>
            <dc:creator><![CDATA[陳威寰]]></dc:creator>
            <pubDate>Thu, 23 Jan 2020 17:16:27 GMT</pubDate>
            <atom:updated>2020-01-23T18:29:52.020Z</atom:updated>
            <content:encoded><![CDATA[<p>在製作Unity遊戲的過程中，常常遇到很多麻煩，尤其是像我這個例子:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*K-ttJI1Jap9GhU06sRBuTw.png" /></figure><p>圖片中，我操控的腳色要砍向那隻小怪，本來以為會很順的砍下去，但卻不知道為甚麼遊戲突然暫停了，再看看我當下的程式碼:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e115004833c97654baa20787b474a083/href">https://medium.com/media/e115004833c97654baa20787b474a083/href</a></iframe><pre>using System.Collections;</pre><pre>using System.Collections.Generic;</pre><pre>using UnityEngine;</pre><pre>public class Damage : MonoBehaviour</pre><pre>{</pre><pre>public float damage = 5;</pre><pre>}</pre><p>上面是該小怪的程式碼，下面是上面那個程式所reference的程式，看起來很正常對吧?但執行起來就是會出現那一行訊息。</p><p>所以我查了一下資料:</p><p><a href="https://support.unity3d.com/hc/en-us/articles/206369473-NullReferenceException">NullReferenceException</a></p><p>基本上這個問題就是當你用我上面那個方法的時候，Unity會找不到你要reference的那個腳本在哪，所以我修改了一下我的程式碼:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/193ba45eed6bbcfe631759a366de063c/href">https://medium.com/media/193ba45eed6bbcfe631759a366de063c/href</a></iframe><p>可以看到我把在Awake()函式中做了一些修改，因為我把腳本Damage套在主角SKELETON上，所以必須要讓系統找到SKELETON，它才能再找到Damage這個腳本，之後便能順利運行啦。</p><p>以上就是我這次的分享。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e632ee51553" width="1" height="1" alt=""><hr><p><a href="https://medium.com/will-unity/%E9%97%9C%E6%96%BCnullreferenceexception%E7%9A%84%E5%95%8F%E9%A1%8C-9e632ee51553">關於NullReferenceException的問題</a> was originally published in <a href="https://medium.com/will-unity">Unity</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>