【问题标题】:Get String attribute in SCNText获取 SCNText 中的字符串属性
【发布时间】:2017-08-18 05:01:39
【问题描述】:

我有一个 SCNText 元素:

print(NodeElement?.geometry?)

// output
`Optional(<SCNText: 0x1c01f6800 'text' | 3 elements | string=At desk extrusionDepth=0.500> )`

但是,当我这样做时:

print(self.editingSCNBodyNode?.geometry?.string)

我得到错误:

Value of type 'SCNGeometry' has no member 'string'

根据 Apple 的documentation,这是可以获取和设置的变量。

【问题讨论】:

    标签: ios swift scenekit


    【解决方案1】:

    SCNTextSCNGeometry 的子类。的类型 self.editingSCNBodyNode?.geometrySCNGeometry? 你有 有条件地贬低它:

    if let scnText = self.editingSCNBodyNode?.geometry as? SCNText {
        print(scnText.string)
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-29
      • 1970-01-01
      • 1970-01-01
      • 2018-11-28
      • 1970-01-01
      • 2011-05-18
      • 2018-03-10
      相关资源
      最近更新 更多