为什么我无法从Unity3D中的自定义类创建对象?

时间:2020-10-05 17:40:02

标签: c# unity3d

该对象将不会显示在层次结构中,并且在从MonoBehaviour派生的其他脚本中,调用GameObject.Find(“ / Canvas”)将为空。


//function that returns closure to be used as one of parallel jobs
def buildSingleJobParallel(steps, mjob){ 
    return {
        def result = steps.build job: mjob.fullName, propagate: false
        steps.echo "${mjob.fullName} finished: ${steps.result.rawBuild.result}"
        if (result.rawBuild.result.isWorseThan(Result.SUCCESS)) {
            steps.currentBuild.result = 'FAILURE'
        }
    }
}



stage('Integration Test Run') {
    steps {
        script {
            //build map<jobName, Closure> and run jobs in parallel
            parallel matchingJobs.collectEntries{mjob-> [mjob.name, buildSingleJobParallel(this, mjob)]}
        }
    }
}

1 个答案:

答案 0 :(得分:0)

那是因为我改变了场景。我应该添加

DontDestroyOnLoad(canvas);

之后

canvas = GameObject.Find("/Canvas") ?? new GameObject("Canvas");