测试代码
This commit is contained in:
@@ -74,21 +74,18 @@ namespace NBF
|
||||
_camera.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void LoadModel(string model, ModelViewerSettings settings)
|
||||
public void SetModel(GameObject model, ModelViewerSettings settings)
|
||||
{
|
||||
this.UnloadModel();
|
||||
ViewerSettings = settings;
|
||||
|
||||
Object prefab = Resources.Load(model);
|
||||
if (prefab == null) return;
|
||||
GameObject go = ((GameObject)Object.Instantiate(prefab));
|
||||
var joint = go.GetComponent<Joint>();
|
||||
if (model == null) return;
|
||||
var joint = model.GetComponent<Joint>();
|
||||
if (joint != null)
|
||||
{
|
||||
Object.Destroy(joint);
|
||||
}
|
||||
|
||||
_model = go.transform;
|
||||
_model = model.transform;
|
||||
_model.SetParent(this.modelRoot, false);
|
||||
_model.localPosition = Vector3.zero;
|
||||
_model.localScale = Vector3.one;
|
||||
@@ -96,12 +93,40 @@ namespace NBF
|
||||
if (ViewerSettings == null)
|
||||
{
|
||||
ViewerSettings = new ModelViewerSettings();
|
||||
ModelViewerUtils.InitSetting(go, ViewerSettings);
|
||||
ModelViewerUtils.InitSetting(model, ViewerSettings);
|
||||
}
|
||||
|
||||
Review();
|
||||
}
|
||||
|
||||
// public void LoadModel(string model, ModelViewerSettings settings)
|
||||
// {
|
||||
// this.UnloadModel();
|
||||
// ViewerSettings = settings;
|
||||
//
|
||||
// Object prefab = Resources.Load(model);
|
||||
// if (prefab == null) return;
|
||||
// GameObject go = ((GameObject)Object.Instantiate(prefab));
|
||||
// var joint = go.GetComponent<Joint>();
|
||||
// if (joint != null)
|
||||
// {
|
||||
// Object.Destroy(joint);
|
||||
// }
|
||||
//
|
||||
// _model = go.transform;
|
||||
// _model.SetParent(this.modelRoot, false);
|
||||
// _model.localPosition = Vector3.zero;
|
||||
// _model.localScale = Vector3.one;
|
||||
// _model.localEulerAngles = Vector3.zero;
|
||||
// if (ViewerSettings == null)
|
||||
// {
|
||||
// ViewerSettings = new ModelViewerSettings();
|
||||
// ModelViewerUtils.InitSetting(go, ViewerSettings);
|
||||
// }
|
||||
//
|
||||
// Review();
|
||||
// }
|
||||
|
||||
public void UnloadModel()
|
||||
{
|
||||
if (_model != null)
|
||||
|
||||
Reference in New Issue
Block a user