//Call this whenever you change the icMaterial on this gameobject. //E.g. when changing from an icImageMaterial to a icBinkMaterial //Will pick the first enabled icMaterial. If all are disabled, will pick the first one. public void RefreshIcMaterial() { if (icMat != null) { icMat.RemoveRenderPass(this); } this.icMat = null; icMaterial[] icMats = this.GetComponents <icMaterial>(); if (icMats.Length > 0) { for (int i = 0; i < icMats.Length; i++) { icMaterial mat = icMats[i]; if (mat.enabled) { this.icMat = mat; break; } } if (this.icMat == null) { this.icMat = icMats[0]; } this.icMat.AddRenderPass(this); } else { Debug.LogWarning("icRenderPass was added to a GameObject with no icMaterial"); } }
public void drawColour() { if (toView.renderer && toView.renderer.material) //check if colour exists. { if (!toView.renderer.material.HasProperty("_Color")) { return; } Color c; icMaterial icMat = toView.GetComponent <icMaterial>(); if (icMat == null) { c = toView.renderer.material.GetColor("_Color"); } else { c = icMat.icColour; } c = this.colourPicker.DrawGUI(c); if (icMat != null) { icMat.icColour = c; } else { toView.renderer.material.SetColor("_Color", c); } } }
void UpdateStereoChild(icMaterial icMat) { if (icMat) { icMat.baseScale = this.baseScale; icMat.autoAspectRatio = this.autoAspectRatio; icMat.keepStartingAspectRatio = this.keepStartingAspectRatio; } }
void Start() { SetStereoMode(leftObject, StereoMode.LEFT); SetStereoMode(rightObject, StereoMode.RIGHT); leftObject.transform.parent = this.transform; rightObject.transform.parent = this.transform; this.leftIcMat = this.leftObject.GetComponent <icMaterial>(); this.rightIcMat = this.rightObject.GetComponent <icMaterial>(); UpdateStereoChild(this.leftIcMat); UpdateStereoChild(this.rightIcMat); LinkMediaReadies(); }
protected StereoMediaReady LinkSingleMediaReady(icMaterial stereoChildMat) { if (stereoChildMat) { StereoMediaReady mrScript = this.gameObject.AddComponent <StereoMediaReady>(); mrScript.enabled = false; stereoChildMat.mediaReadyCallbacks.Add(mrScript); return(mrScript); } else { return(null); } }
void SetStereoMode(GameObject go, StereoMode sm) { icMaterial icMat = go.GetComponent <icMaterial>(); if (icMat) { icMat.stereoMode = sm; // Always true so we can adjust colour from the stereo parent icMat.multiplyByParentColour = true; } else { int layerNum = ToolbeltManager.FirstInstance.GetStereoLayer(sm); go.layer = layerNum; } }
/// Update the Unity Material colour based on the current icColour, /// and propagate the change down to the children protected virtual void UpdateEffectiveColour() { prevIcColour = icColour; prevMultiplyByParentColour = multiplyByParentColour; if (this.multiplyByParentColour && this.transform.parent != null) { Color parentColour; //check if it has an icMaterial if (this.transform.parent.renderer != null) { parentColour = this.transform.parent.renderer.material.color; } else { icMaterial parentIcMat = this.transform.parent.GetComponent <icMaterial>(); if (parentIcMat != null) { parentColour = parentIcMat.getFinalColour(); } else { parentColour = new Color(1.0f, 1.0f, 1.0f, 1.0f); } } this.finalColour = parentColour * icColour; if (this.renderer) { this.renderer.material.SetColor("_Color", finalColour); } } else { this.finalColour = icColour; if (this.renderer) { this.renderer.material.SetColor("_Color", icColour); } } PropagateColourChange(); }
public void SetIcMaterial(icMaterial icm) { this.icMat = icm; }
void Awake() { attachedIcMat = this.GetComponent <icMaterial>() as icMaterial; }