private void LoadControllerFromSystem(int id) { var sysControllerName = controllerType.ToString() + id.ToString() + ".obj"; var fullFilePath = modelFilePath + sysControllerName; if (!File.Exists(fullFilePath)) { Debug.Log("PXRLog Load Obj From Prefab"); } else { GameObject go = new GameObject(); go.name = modelName; MeshFilter meshFilter = go.AddComponent <MeshFilter>(); meshFilter.mesh = PXR_ObjImporter.Instance.ImportFile(fullFilePath); go.transform.SetParent(transform); go.transform.localPosition = Vector3.zero; MeshRenderer meshRenderer = go.AddComponent <MeshRenderer>(); int matID = (int)curControllerData["material_type"]; meshRenderer.material = matID == 0 ? standardMaterial : mobileMaterial; loadModelSuccess = true; PXR_ControllerKeyEffects controllerVisual = go.AddComponent <PXR_ControllerKeyEffects>(); controllerVisual.hand = hand; LoadTexture(controllerVisual, controllerType.ToString() + id.ToString(), false); go.transform.localRotation = Quaternion.Euler(new Vector3(0, 180, 0)); go.transform.localScale = new Vector3(-0.01f, 0.01f, 0.01f); } }
private void LoadTexture(PXR_ControllerKeyEffects visual, string controllerName, bool fromRes) { if (fromRes) { texFormat = ""; prePath = controllerName; } else { texFormat = "." + (string)curControllerData["tex_format"]; prePath = modelFilePath + controllerName; } var texturePath = prePath + "_idle" + texFormat; visual.textureIdle = LoadOneTexture(texturePath, fromRes); texturePath = prePath + "_app" + texFormat; visual.textureApp = LoadOneTexture(texturePath, fromRes); texturePath = prePath + "_home" + texFormat; visual.textureHome = LoadOneTexture(texturePath, fromRes); texturePath = prePath + "_touch" + texFormat; visual.textureTouchpad = LoadOneTexture(texturePath, fromRes); texturePath = prePath + "_volume_down" + texFormat; visual.textureVolDown = LoadOneTexture(texturePath, fromRes); texturePath = prePath + "_volume_up" + texFormat; visual.textureVolUp = LoadOneTexture(texturePath, fromRes); texturePath = prePath + "_trigger" + texFormat; visual.textureTrigger = LoadOneTexture(texturePath, fromRes); texturePath = prePath + "_a" + texFormat; visual.textureA = LoadOneTexture(texturePath, fromRes); texturePath = prePath + "_b" + texFormat; visual.textureB = LoadOneTexture(texturePath, fromRes); texturePath = prePath + "_x" + texFormat; visual.textureX = LoadOneTexture(texturePath, fromRes); texturePath = prePath + "_y" + texFormat; visual.textureY = LoadOneTexture(texturePath, fromRes); texturePath = prePath + "_grip" + texFormat; visual.textureGrip = LoadOneTexture(texturePath, fromRes); }