国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

【解決】ArgumentException: GetComponent requires that the requested component ‘XX‘ derives from...

這篇具有很好參考價(jià)值的文章主要介紹了【解決】ArgumentException: GetComponent requires that the requested component ‘XX‘ derives from...。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

開發(fā)平臺(tái):Unity 2020
編程平臺(tái):Visual Studio 2020
使用語(yǔ)言:CSharp
?

一、問(wèn)題描述


【解決】ArgumentException: GetComponent requires that the requested component ‘XX‘ derives from...
備注:這是一個(gè)開發(fā)者對(duì) Unity 認(rèn)知存在錯(cuò)誤所產(chǎn)生的方法。

?
問(wèn)題代碼信息:

var thisMat = transform.GetComponent<Materials>();

?

二、問(wèn)題原因


2.1 理解:成為 Component 的條件

【解決】ArgumentException: GetComponent requires that the requested component ‘XX‘ derives from...
??在 Unity 中成為 Component 的條件是繼承于 MonoBehaviour 類對(duì)象。該繼承模式下的腳本將允許以組件視窗模式呈現(xiàn)。即 Inspector 屬性面板上的掛載。原則上,只要是能夠在游戲?qū)ο笊咸砑拥膶?duì)象均有繼承 MonoBehaviour。
?

2.2 理解:Component 與 Material 關(guān)系

【解決】ArgumentException: GetComponent requires that the requested component ‘XX‘ derives from...
?? GetComponent<T>() 通常作為索引組件具體對(duì)象。此處涉及其爺爺對(duì)象 Component 類。該 Component 類是 MonoBehaviour 的爺爺類。但同時(shí)也是 Material 的旁系子類(即 object 父類)。
?
最終解釋:在擁有同系父類的情況下,出現(xiàn) GetComponent<Material>() 卻 “未提示該行代碼異?!?的原因也就清晰明了。因?yàn)?Material 并未直接或間接繼承 Component 類。

?

三、解決方案:使用繼承 Component 對(duì)象進(jìn)行索引屬性。


public void Example()
{
	var thisMaterial = transform.GetComponent<MeshRenderer>().Materials[0];
}

??為方便管理這類特別的繼承關(guān)系對(duì)象。例如 Material 能夠在 MeshRenderer 組件中被找到??梢允褂?GetComponents<MeshRenderer>().Materials 獲取對(duì)象。如果細(xì)致能發(fā)現(xiàn) MeshRenderer 繼承于 Renderer 類。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-429736.html

到了這里,關(guān)于【解決】ArgumentException: GetComponent requires that the requested component ‘XX‘ derives from...的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 已解決stderr: ERROR: Could not find a version that satisfies the requirement gradio==3.23

    已解決stderr: ERROR: Could not find a version that satisfies the requirement gradio==3.23

    已解決stderr: ERROR: Could not find a version that satisfies the requirement gradio==3.23 ERROR: No matching distribution found for gradio==3.23 粉絲群里面的一個(gè)小伙伴遇到問(wèn)題跑來(lái)私信我,想用pip安裝gradio,但是發(fā)生了報(bào)錯(cuò)(當(dāng)時(shí)他心里瞬間涼了一大截,跑來(lái)找我求助,然后順利幫助他解決了,順便記錄

    2023年04月17日
    瀏覽(99)
  • 解決 ERROR: Could not find a version that satisfies the requirement torch==1.10.0+cu102

    解決 ERROR: Could not find a version that satisfies the requirement torch==1.10.0+cu102

    筆者的問(wèn)題不是網(wǎng)絡(luò)問(wèn)題 python版本:3.10 本機(jī)CUDA版本:10.2 OS:Windows10 下載torch時(shí)報(bào)錯(cuò): python3.10目前在pytorch提供的庫(kù)中根本沒(méi)有對(duì)應(yīng)的windows10環(huán)境的torch庫(kù) https://download.pytorch.org/whl/torch 注:cu代表CUDA版本,cp代表python版本 安裝python3.8,注意添加環(huán)境變量 然后以管理員身份打

    2024年02月02日
    瀏覽(119)
  • Anaconda中安裝tensorflow報(bào)錯(cuò):Could not find a version that satisfies the requirement tensorflow的解決辦法

    Anaconda中安裝tensorflow報(bào)錯(cuò):Could not find a version that satisfies the requirement tensorflow的解決辦法

    在jupyter notebook 學(xué)習(xí)tensorflow相關(guān),提示 No module named ‘tensorflow’,所以要安裝tensorflow包。 但是在安裝時(shí),總是提示: ERROR:Could not find a version that satisfies the requirement tensorflow 如下圖所示,無(wú)論指定什么版本,使用哪個(gè)鏡像源都不行。 進(jìn)行了以下排查: python版本,我的Pyth

    2024年02月08日
    瀏覽(27)
  • 如何解決Python pip的版本匹配錯(cuò)誤:ERROR: Could not find a version that satisfies the requirement

    如何解決Python pip的版本匹配錯(cuò)誤:ERROR: Could not find a version that satisfies the requirement

    博主貓頭虎的技術(shù)世界 ?? 歡迎來(lái)到貓頭虎的博客 — 探索技術(shù)的無(wú)限可能! 專欄鏈接 : ?? 精選專欄 : 《面試題大全》 — 面試準(zhǔn)備的寶典! 《IDEA開發(fā)秘籍》 — 提升你的IDEA技能! 《100天精通鴻蒙》 — 從Web/安卓到鴻蒙大師! 《100天精通Golang(基礎(chǔ)入門篇)》 — 踏入

    2024年04月16日
    瀏覽(101)
  • Python安裝包報(bào)錯(cuò)ERROR: Could not find a version that satisfies the requirement XXX解決方法

    我們?cè)谑褂?pip 安裝 python 包時(shí),經(jīng)常會(huì)出現(xiàn)如下錯(cuò)誤: 找了很久終于找到能解決這種報(bào)錯(cuò)的方法了。 直接選用pip源并且信任它的來(lái)源就可以解決這種問(wèn)題。 上面使用了豆瓣源,將其換成清華源、阿里源等都適用。 清華源: Simple Index

    2024年02月11日
    瀏覽(94)
  • 解決WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python

    目錄 解決WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python不可用 的問(wèn)題 問(wèn)題描述 解決方案 1. 檢查Python環(huán)境 2. 安裝所需的依賴 對(duì)于Debian/Ubuntu系統(tǒng): 對(duì)于Fedora/CentOS系統(tǒng): 對(duì)于MacOS系統(tǒng): 對(duì)于Windows系統(tǒng): 3. 重新安裝Python環(huán)境 4. 使用另一個(gè)包管理器

    2024年02月05日
    瀏覽(23)
  • 已解決WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python

    已解決WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python

    已解決(pip升級(jí)報(bào)錯(cuò)) WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: pip in e:anacondainstall_rootlibsite-packages (21.0.1) WARNING: Retrying (Retry(total=4, connect=None, read=None, redi

    2024年02月02日
    瀏覽(24)
  • Python pip install 安裝包報(bào)錯(cuò)ERROR: Could not find a version that satisfies the requirement XXX解決方法

    Python pip install 安裝包報(bào)錯(cuò)ERROR: Could not find a version that satisfies the requirement XXX解決方法

    使用 pip 安裝 python 包時(shí),經(jīng)常會(huì)出現(xiàn)如下錯(cuò)誤: 本次在用pip命令(pip install pdf2word)安裝pdf2docx包的時(shí)候出錯(cuò) 因?yàn)楹髞?lái)安裝好了,所以故意安裝一個(gè)錯(cuò)誤的pdf2word,來(lái)整個(gè)圖 可能是國(guó)內(nèi)網(wǎng)絡(luò)不穩(wěn)定,直接導(dǎo)致報(bào)錯(cuò),而不是環(huán)境沖突。報(bào)錯(cuò)信息看起來(lái)容易把人誤導(dǎo)到解決包環(huán)境

    2024年01月18日
    瀏覽(107)
  • python使用pip安裝包報(bào)錯(cuò)的解決辦法(ERROR: Could not find a version that satisfies the requirement XXX)

    python使用pip安裝包報(bào)錯(cuò)的解決辦法(ERROR: Could not find a version that satisfies the requirement XXX)

    目錄 解決方法一:更換下載源 解決方法二:使用源碼安裝 解決方法三:通過(guò)whl文件安裝 拓展:虛擬環(huán)境下通過(guò)源碼安裝第三方庫(kù) 使用pip命令安裝python包時(shí)可能會(huì)出現(xiàn)如下錯(cuò)誤提示: ERROR: Could not find a version that satisfies the requirement XXX (from v ersions: none) ERROR: No matching distribu

    2024年01月19日
    瀏覽(118)
  • ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none)問(wèn)題原因及解決方法

    ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none)問(wèn)題原因及解決方法

    出現(xiàn)沒(méi)安裝該庫(kù)提示,于是使用命令下載 但是報(bào)錯(cuò) 應(yīng)該是庫(kù)的名字變了,我用Pycharm的工具Pypi查看,發(fā)現(xiàn)搜索cv最頂上的那個(gè)是opencv-python,于是我又安裝了這個(gè)庫(kù),報(bào)錯(cuò)就消失了 使用這條命令 或者在PyPI里面直接點(diǎn)擊安裝 問(wèn)題就解決啦! 通過(guò)手機(jī)熱點(diǎn)連接網(wǎng)絡(luò),別翻墻,別

    2024年02月08日
    瀏覽(91)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包