Example #1
0
    // Use this for initialization
    void Start()
    {
#if UNITY_EDITOR
        if (Application.isEditor)
        {
            return;
        }
#endif
        if (WaveVR.Instance == null)
        {
            Log.w(LOG_TAG, "Fail to initialize!");
            return;
        }
        wvrRes = WaveVR_Resource.instance;

        if (wvrRes == null)
        {
            Log.w(LOG_TAG, "Failed to initial WaveVR Resource instance!");
        }
        else
        {
            string lang    = wvrRes.getSystemLanguage();
            string country = wvrRes.getSystemCountry();
            Log.d(LOG_TAG, "system default language is " + lang);
            Log.d(LOG_TAG, "system default country is " + country);
        }

        pmInstance = WaveVR_PermissionManager.instance;
        if (pmInstance != null)
        {
            StartCoroutine(checkPackageManagerStatus());
        }
        //Interop.WVR_SetArenaVisible(WVR_ArenaVisible.WVR_ArenaVisible_Auto);
    }
	// reset for redraw
	void resetIndicator()
	{
		if (showIndicator)
		{
			rw = WaveVR_Resource.instance;
			sysLang = rw.getSystemLanguage();
			sysCountry = rw.getSystemCountry();

			needRedraw = true;
			clearResourceAndObject();
		}
	}
    // Update is called once per frame
    void Update()
    {
        if (!showIndicator)
        {
            return;
        }
        if (_HMD == null)
        {
            return;
        }
#if !UNITY_EDITOR
        checkCount++;
        if (checkCount > 50)
        {
            checkCount = 0;
            if (rw.getSystemLanguage() != sysLang || rw.getSystemCountry() != sysCountry)
            {
                resetIndicator();
            }
        }
#endif
        if (needRedraw == true)
        {
            createIndicator();
        }

        Vector3 _targetForward = transform.rotation * Vector3.forward;
        Vector3 _targetRight   = transform.rotation * Vector3.right;
        Vector3 _targetUp      = transform.rotation * Vector3.up;

        float zAngle = Vector3.Angle(_targetForward, _HMD.transform.forward);
        float xAngle = Vector3.Angle(_targetRight, _HMD.transform.right);
        float yAngle = Vector3.Angle(_targetUp, _HMD.transform.up);

#if DEBUG
        Log.gpl.d(LOG_TAG, "Z: " + _targetForward + ":" + zAngle + ", X: " + _targetRight + ":" + xAngle + ", Y: " + _targetUp + ":" + yAngle);
#endif
        if ((_targetForward.y < (showIndicatorAngle / 90f)) || (zAngle < showIndicatorAngle))
        {
            foreach (ComponentsIndication ci in compInd)
            {
                ci.LineIndicator.SetActive(false);
                ci.DestObject.SetActive(false);
            }

            return;
        }

        if (hideIndicatorByRoll)
        {
            if (xAngle > 90.0f)
            //if ((_targetRight.x < 0f) || (xAngle > 90f))
            {
                foreach (ComponentsIndication ci in compInd)
                {
                    ci.LineIndicator.SetActive(false);
                    ci.DestObject.SetActive(false);
                }

                return;
            }
        }

        foreach (ComponentsIndication ci in compInd)
        {
            if (ci.LineIndicator != null)
            {
                ci.LineIndicator.SetActive(true);
            }

            if (ci.DestObject != null)
            {
                ci.DestObject.SetActive(true);
                if (ci.followButtonRoration == false)
                {
                    ci.LineIndicator.transform.position = ci.SourceObject.transform.position + ci.Offset;
                    if (ci.alignment == ButtonIndication.Alignment.RIGHT)
                    {
                        ci.DestObject.transform.position = new Vector3(transform.position.x + lineLength, ci.SourceObject.transform.position.y, ci.SourceObject.transform.position.z) + ci.Offset;
                    }
                    else
                    {
                        ci.DestObject.transform.position = new Vector3(transform.position.x - lineLength, ci.SourceObject.transform.position.y, ci.SourceObject.transform.position.z) + ci.Offset;

                        TextMesh[] texts = ci.DestObject.GetComponentsInChildren <TextMesh>();
                        foreach (TextMesh tm in texts)
                        {
                            if (tm != null)
                            {
                                tm.anchor    = TextAnchor.MiddleRight;
                                tm.alignment = TextAlignment.Right;
                            }
                        }
                    }

                    Transform[] transforms = ci.DestObject.GetComponentsInChildren <Transform>();
                    foreach (Transform tf in transforms)
                    {
                        if (tf != null)
                        {
                            tf.rotation = Quaternion.identity;
                        }
                    }
                }
            }
        }
    }
    void createIndicator()
    {
        if (!showIndicator)
        {
            return;
        }
        clearResourceAndObject();
        PrintDebugLog("create Indicator!");
#if !UNITY_EDITOR
        rw = WaveVR_Resource.instance;
#endif
        indicatorPrefab = Resources.Load("ComponentIndicator") as GameObject;

        if (indicatorPrefab == null)
        {
            PrintDebugLog("ComponentIndicator is not found!");
            return;
        }
        else
        {
            PrintDebugLog("ComponentIndicator is found!");
        }

        linePrefab = Resources.Load("LineIndicator") as GameObject;

        if (linePrefab == null)
        {
            PrintDebugLog("LineIndicator is not found!");
            return;
        }
        else
        {
            PrintDebugLog("LineIndicator is found!");
        }

        if (_HMD == null)
        {
            _HMD = WaveVR_Render.Instance.gameObject;
        }

        if (_HMD == null)
        {
            PrintDebugLog("Can't get HMD!");
            return;
        }
        PrintDebugLog("showIndicatorAngle: " + showIndicatorAngle + ", hideIndicatorByRoll: " + hideIndicatorByRoll);
        PrintDebugLog("Line settings--\n lineLength: " + lineLength + ", lineStartWidth: " + lineStartWidth + ", lineEndWidth: " + lineEndWidth + ", lineColor: " + lineColor);
        PrintDebugLog("Text settings--\n textCharacterSize: " + textCharacterSize + ", zhCharactarSize: " + zhCharactarSize + ", textFontSize: " + textFontSize + ", textColor: " + textColor);

        foreach (ButtonIndication bi in buttonIndicationList)
        {
            PrintDebugLog("keyType: " + bi.keyType + ", alignment: " + bi.alignment + ", offset: " + bi.indicationOffset +
                          ", indication: " + bi.indicationText + ", followRotation: " + bi.followButtonRotation);

            // find component by name
            string partName      = null;
            string indicationKey = null;
            switch (bi.keyType)
            {
            case ButtonIndication.KeyIndicator.AppButton:
                partName      = "_[CM]_AppButton";
                indicationKey = "AppKey";
                break;

            case ButtonIndication.KeyIndicator.BumperKey:
                partName      = "_[CM]_BumperKey";
                indicationKey = "BumperKey";
                break;

            case ButtonIndication.KeyIndicator.HomeButton:
                partName      = "_[CM]_HomeButton";
                indicationKey = "HomeKey";
                break;

            case ButtonIndication.KeyIndicator.TouchPad:
                partName      = "_[CM]_TouchPad";
                indicationKey = "TouchPad";
                break;

            case ButtonIndication.KeyIndicator.TriggerKey:
                partName      = "_[CM]_TriggerKey";
                indicationKey = "TriggerKey";
                break;

            case ButtonIndication.KeyIndicator.VolumeKey:
                partName      = "_[CM]_VolumeKey";
                indicationKey = "VolumeKey";
                break;

            default:
                partName      = "_[CM]_unknown";
                indicationKey = "unknown";
                PrintDebugLog("Unknown key type!");
                break;
            }

            Transform tmp = transform.Find(partName);

            if (tmp != null)
            {
                ComponentsIndication tmpCom = new ComponentsIndication();

                tmpCom.Name                 = partName;
                tmpCom.SourceObject         = tmp.gameObject;
                tmpCom.alignment            = bi.alignment;
                tmpCom.followButtonRoration = bi.followButtonRotation;

                Vector3 linePos;
                tmpCom.LineIndicator = null;

                linePos = transform.TransformPoint(new Vector3(0, tmp.localPosition.y, tmp.localPosition.z) + bi.indicationOffset);
                Quaternion spawnRot = Quaternion.identity;
                if (bi.followButtonRotation == true)
                {
                    spawnRot = transform.rotation;
                }

                GameObject lineGO = Instantiate(linePrefab, linePos, spawnRot);
                lineGO.name = partName + "Line";

                var li = lineGO.GetComponent <IndicatorLine>();
                li.lineColor  = lineColor;
                li.lineLength = lineLength;
                li.startWidth = lineStartWidth;
                li.endWidth   = lineEndWidth;
                li.alignment  = bi.alignment;
                li.updateMeshSettings();

                if (bi.followButtonRotation == true)
                {
                    lineGO.transform.parent = tmpCom.SourceObject.transform;
                }
                lineGO.SetActive(false);
                tmpCom.LineIndicator = lineGO;

                tmpCom.DestObject = null;

                Vector3 spawnPos;
                if (bi.alignment == ButtonIndication.Alignment.RIGHT)
                {
                    spawnPos = transform.TransformPoint(new Vector3(lineLength, tmp.localPosition.y, tmp.localPosition.z) + bi.indicationOffset);
                }
                else
                {
                    spawnPos = transform.TransformPoint(new Vector3(lineLength * (-1), tmp.localPosition.y, tmp.localPosition.z) + bi.indicationOffset);
                }

                GameObject destGO = Instantiate(indicatorPrefab, spawnPos, transform.rotation);
                destGO.name = partName + "Ind";
                if (bi.followButtonRotation == true)
                {
                    destGO.transform.parent = tmpCom.SourceObject.transform;
                }

                PrintDebugLog(" Source PartName: " + tmp.gameObject.name + " pos: " + tmp.position + " Rot: " + tmp.rotation);
                PrintDebugLog(" Line Name: " + lineGO.name + " pos: " + lineGO.transform.position + " Rot: " + lineGO.transform.rotation);
                PrintDebugLog(" Destination Name: " + destGO.name + " pos: " + destGO.transform.position + " Rot: " + destGO.transform.rotation);

                int childC = destGO.transform.childCount;
                for (int i = 0; i < childC; i++)
                {
                    GameObject c = destGO.transform.GetChild(i).gameObject;
                    if (bi.alignment == ButtonIndication.Alignment.LEFT)
                    {
                        float tx = c.transform.localPosition.x;
                        c.transform.localPosition = new Vector3(tx * (-1), c.transform.localPosition.y, c.transform.localPosition.z);
                    }
                    TextMesh     tm = c.GetComponent <TextMesh>();
                    MeshRenderer mr = c.GetComponent <MeshRenderer>();

                    if (tm == null)
                    {
                        PrintDebugLog(" tm is null ");
                    }
                    if (mr == null)
                    {
                        PrintDebugLog(" mr is null ");
                    }

                    if (tm != null && mr != null)
                    {
                        tm.characterSize = textCharacterSize;
                        if (c.name != "Shadow")
                        {
                            mr.material.SetColor("_Color", textColor);
                        }
                        else
                        {
                            PrintDebugLog(" Shadow found ");
                        }
                        tm.fontSize = textFontSize;
#if !UNITY_EDITOR
                        if (bi.indicationText == "system")
                        {
                            sysLang    = rw.getSystemLanguage();
                            sysCountry = rw.getSystemCountry();
                            PrintDebugLog(" System language is " + sysLang);
                            if (sysLang.StartsWith("zh"))
                            {
                                PrintDebugLog(" Chinese language");
                                tm.characterSize = zhCharactarSize;
                            }

                            // use default string - multi-language
                            tm.text = rw.getString(indicationKey);
                            PrintDebugLog(" Name: " + destGO.name + " uses default multi-language -> " + tm.text);
                        }
                        else
                        {
                            tm.text = bi.indicationText;
                        }
#else
                        tm.text = indicationKey;
#endif

                        if (bi.alignment == ButtonIndication.Alignment.LEFT)
                        {
                            tm.anchor    = TextAnchor.MiddleRight;
                            tm.alignment = TextAlignment.Right;
                        }
                    }
                }

                destGO.SetActive(false);
                tmpCom.DestObject = destGO;
                tmpCom.Offset     = bi.indicationOffset;

                PrintDebugLog(tmpCom.Name + " line -> " + tmpCom.LineIndicator.name + " destObjName -> " + tmpCom.DestObject.name);
                compInd.Add(tmpCom);
            }
            else
            {
                PrintDebugLog(partName + " is not in the model!");
            }
        }

        needRedraw = false;
    }
Example #5
0
 public void getCountryandLanguage()
 {
     //Log.d(LOG_TAG, "getCountryandLanguage " + rw.getSystemCountry() + " \nLanguage : " + rw.getSystemLanguage());
     displayText = "location country : " + rw.getSystemCountry() + " \nLanguage : " + rw.getSystemLanguage();
     _text.text  = displayText;
 }
	public void createIndicator() {
		if (!showIndicator) return;
		clearResourceAndObject();
		PrintDebugLog("create Indicator!");
		rw = WaveVR_Resource.instance;
		indicatorPrefab = Resources.Load("ComponentIndicator") as GameObject;

		if (indicatorPrefab == null)
		{
			PrintInfoLog("ComponentIndicator is not found!");
			return;
		}
		else
		{
			PrintDebugLog("ComponentIndicator is found!");
		}

		linePrefab = Resources.Load("LineIndicator") as GameObject;

		if (linePrefab == null)
		{
			PrintInfoLog("LineIndicator is not found!");
			return;
		}
		else
		{
			PrintDebugLog("LineIndicator is found!");
		}

		if (_HMD == null)
			_HMD = WaveVR_Render.Instance.gameObject;

		if (_HMD == null)
		{
			PrintInfoLog("Can't get HMD!");
			return;
		}

		var gc = transform.childCount;

		for (int i = 0; i < gc; i++)
		{
			GameObject go = transform.GetChild(i).gameObject;

			PrintInfoLog("child name is " + go.name);
		}

		PrintInfoLog("showIndicatorAngle: " + showIndicatorAngle + ", hideIndicatorByRoll: " + hideIndicatorByRoll + ", basedOnEmitter: " + basedOnEmitter);
		PrintInfoLog("Line settings--\n lineLength: " + lineLength + ", lineStartWidth: " + lineStartWidth + ", lineEndWidth: " + lineEndWidth + ", lineColor: " + lineColor);
		PrintInfoLog("Text settings--\n textCharacterSize: " + textCharacterSize + ", zhCharactarSize: " + zhCharactarSize + ", textFontSize: " + textFontSize + ", textColor: " + textColor);

		foreach (ButtonIndication bi in buttonIndicationList)
		{
			PrintInfoLog("keyType: " + bi.keyType + ", alignment: " + bi.alignment + ", offset: " + bi.indicationOffset + ", useMultiLanguage: " + bi.useMultiLanguage +
				", indication: " + bi.indicationText + ", followRotation: " + bi.followButtonRotation);

			// find component by name
			string partName = null;
			string partName1 = null;
			string partName2 = null;
			string indicationKey = null;
			switch(bi.keyType)
			{
				case ButtonIndication.KeyIndicator.Trigger:
					partName = "_[CM]_TriggerKey";
					partName1 = "__CM__TriggerKey";
					partName2 = "__CM__TriggerKey.__CM__TriggerKey";
					indicationKey = "TriggerKey";
					break;
				case ButtonIndication.KeyIndicator.TouchPad:
					partName = "_[CM]_TouchPad";
					partName1 = "__CM__TouchPad";
					partName2 = "__CM__TouchPad.__CM__TouchPad";
					indicationKey = "TouchPad";
					break;
				case ButtonIndication.KeyIndicator.Grip:
					partName = "_[CM]_Grip";
					partName1 = "__CM__Grip";
					partName2 = "__CM__Grip.__CM__Grip";
					indicationKey = "Grip";
					break;
				case ButtonIndication.KeyIndicator.DPad_Left:
					partName = "_[CM]_DPad_Left";
					partName1 = "__CM__DPad_Left";
					partName2 = "__CM__DPad_Left.__CM__DPad_Left";
					indicationKey = "DPad_Left";
					break;
				case ButtonIndication.KeyIndicator.DPad_Right:
					partName = "_[CM]_DPad_Right";
					partName1 = "__CM__DPad_Right";
					partName2 = "__CM__DPad_Right.__CM__DPad_Right";
					indicationKey = "DPad_Right";
					break;
				case ButtonIndication.KeyIndicator.DPad_Up:
					partName = "_[CM]_DPad_Up";
					partName1 = "__CM__DPad_Up";
					partName2 = "__CM__DPad_Up.__CM__DPad_Up";
					indicationKey = "DPad_Up";
					break;
				case ButtonIndication.KeyIndicator.DPad_Down:
					partName = "_[CM]_DPad_Down";
					partName1 = "__CM__DPad_Down";
					partName2 = "__CM__DPad_Down.__CM__DPad_Down";
					indicationKey = "DPad_Down";
					break;
				case ButtonIndication.KeyIndicator.App:
					partName = "_[CM]_AppButton";
					partName1 = "__CM__AppButton";
					partName2 = "__CM__AppButton.__CM__AppButton";
					indicationKey = "AppKey";
					break;
				case ButtonIndication.KeyIndicator.Home:
					partName = "_[CM]_HomeButton";
					partName1 = "__CM__HomeButton";
					partName2 = "__CM__HomeButton.__CM__HomeButton";
					indicationKey = "HomeKey";
					break;
				case ButtonIndication.KeyIndicator.Volume:
					partName = "_[CM]_VolumeKey";
					partName1 = "__CM__VolumeKey";
					partName2 = "__CM__VolumeKey.__CM__VolumeKey";
					indicationKey = "VolumeKey";
					break;
				case ButtonIndication.KeyIndicator.VolumeUp:
					partName = "_[CM]_VolumeUp";
					partName1 = "__CM__VolumeUp";
					partName2 = "__CM__VolumeUp.__CM__VolumeUp";
					indicationKey = "VolumeUp";
					break;
				case ButtonIndication.KeyIndicator.VolumeDown:
					partName = "_[CM]_VolumeDown";
					partName1 = "__CM__VolumeDown";
					partName2 = "__CM__VolumeDown.__CM__VolumeDown";
					indicationKey = "VolumeDown";
					break;
				case ButtonIndication.KeyIndicator.DigitalTrigger:
					partName = "_[CM]_DigitalTriggerKey";
					partName1 = "__CM__DigitalTriggerKey";
					partName2 = "__CM__DigitalTriggerKey.__CM__DigitalTriggerKey";
					indicationKey = "DigitalTriggerKey";
					break;
				case ButtonIndication.KeyIndicator.Bumper:
					partName = "_[CM]_BumperKey";
					partName1 = "__CM__BumperKey";
					partName2 = "__CM__BumperKey.__CM__BumperKey";
					indicationKey = "BumperKey";
					break;
				case ButtonIndication.KeyIndicator.ButtonA:
					partName = "_[CM]_ButtonA";
					partName1 = "__CM__ButtonA";
					partName2 = "__CM__ButtonA.__CM__ButtonA";
					indicationKey = "ButtonA";
					break;
				case ButtonIndication.KeyIndicator.ButtonB:
					partName = "_[CM]_ButtonB";
					partName1 = "__CM__ButtonB";
					partName2 = "__CM__ButtonB.__CM__ButtonB";
					indicationKey = "ButtonB";
					break;
				case ButtonIndication.KeyIndicator.ButtonX:
					partName = "_[CM]_ButtonX";
					partName1 = "__CM__ButtonX";
					partName2 = "__CM__ButtonX.__CM__ButtonX";
					indicationKey = "ButtonX";
					break;
				case ButtonIndication.KeyIndicator.ButtonY:
					partName = "_[CM]_ButtonY";
					partName1 = "__CM__ButtonY";
					partName2 = "__CM__ButtonY.__CM__ButtonY";
					indicationKey = "ButtonY";
					break;
				default:
					partName = "_[CM]_unknown";
					partName1 = "__CM__unknown";
					partName2 = "__CM__unknown.__CM__unknown";
					indicationKey = "unknown";
					PrintDebugLog("Unknown key type!");
					break;
			}

			Transform tmp = transform.Find(partName);
			if (tmp == null)
			{
				tmp = transform.Find(partName1);
				if (tmp == null)
				{
					tmp = transform.Find(partName2);
				}
			}

			if (tmp != null)
			{
				ComponentsIndication tmpCom = new ComponentsIndication();

				tmpCom.Name = partName;
				tmpCom.SourceObject = tmp.gameObject;
				tmpCom.alignment = bi.alignment;
				tmpCom.followButtonRoration = bi.followButtonRotation;

				Vector3 linePos;
				tmpCom.LineIndicator = null;

				linePos = transform.TransformPoint(new Vector3(0, tmp.localPosition.y, tmp.localPosition.z) + bi.indicationOffset);
				Quaternion spawnRot = Quaternion.identity;
				if (bi.followButtonRotation == true)
				{
					spawnRot = transform.rotation;
				}

				GameObject lineGO = Instantiate(linePrefab, linePos, spawnRot);
				lineGO.name = partName + "Line";

				var li = lineGO.GetComponent<IndicatorLine>();
				li.autoLayout = autoLayout;
				li.lineColor = lineColor;
				li.lineLength = lineLength;
				li.startWidth = lineStartWidth;
				li.endWidth = lineEndWidth;
				li.alignment = bi.alignment;
				li.updateMeshSettings();

				if (bi.followButtonRotation == true)
				{
					lineGO.transform.parent = tmpCom.SourceObject.transform;
				}
				lineGO.SetActive(false);
				tmpCom.LineIndicator = lineGO;

				tmpCom.DestObject = null;

				Vector3 spawnPos;
				if (bi.alignment == ButtonIndication.Alignment.RIGHT)
				{
					spawnPos = transform.TransformPoint(new Vector3(lineLength, tmp.localPosition.y, tmp.localPosition.z) + bi.indicationOffset);
				} else
				{
					spawnPos = transform.TransformPoint(new Vector3(lineLength * (-1), tmp.localPosition.y, tmp.localPosition.z) + bi.indicationOffset);
				}

				GameObject destGO = Instantiate(indicatorPrefab, spawnPos, transform.rotation);
				destGO.name = partName + "Ind";
				if (bi.followButtonRotation == true)
				{
					destGO.transform.parent = tmpCom.SourceObject.transform;
				}

				PrintInfoLog(" Source PartName: " + tmp.gameObject.name + " pos: " + tmp.position + " Rot: " + tmp.rotation);
				PrintInfoLog(" Line Name: " + lineGO.name + " pos: " + lineGO.transform.position + " Rot: " + lineGO.transform.rotation);
				PrintInfoLog(" Destination Name: " + destGO.name + " pos: " + destGO.transform.position + " Rot: " + destGO.transform.rotation);

				int childC = destGO.transform.childCount;
				for (int i = 0; i < childC; i++)
				{
					GameObject c = destGO.transform.GetChild(i).gameObject;
					if (bi.alignment == ButtonIndication.Alignment.LEFT)
					{
						float tx = c.transform.localPosition.x;
						c.transform.localPosition = new Vector3(tx * (-1), c.transform.localPosition.y, c.transform.localPosition.z);
					}
					TextMesh tm = c.GetComponent<TextMesh>();
					MeshRenderer mr = c.GetComponent<MeshRenderer>();

					if (tm == null) PrintInfoLog(" tm is null ");
					if (mr == null) PrintInfoLog(" mr is null ");

					if (tm != null && mr != null)
					{
						tm.characterSize = textCharacterSize;
						if (c.name != "Shadow")
						{
							mr.material.SetColor("_Color", textColor);
						} else
						{
							PrintDebugLog(" Shadow found ");
						}
						tm.fontSize = textFontSize;
						if (bi.useMultiLanguage)
						{
							sysLang = rw.getSystemLanguage();
							sysCountry = rw.getSystemCountry();
							PrintDebugLog(" System language is " + sysLang);
							if (sysLang.StartsWith("zh"))
							{
								PrintDebugLog(" Chinese language");
								tm.characterSize = zhCharactarSize;
							}

							// use default string - multi-language
							if (bi.indicationText == "system") {
								tm.text = rw.getString(indicationKey);
								PrintInfoLog(" Name: " + destGO.name + " uses default multi-language -> " + tm.text);
							} else {
								tm.text = rw.getString(bi.indicationText);
								PrintInfoLog(" Name: " + destGO.name + " uses custom multi-language -> " + tm.text);
							}
						} else
						{
							if (bi.indicationText == "system")
								tm.text = indicationKey;
							else
								tm.text = bi.indicationText;

							PrintInfoLog(" Name: " + destGO.name + " didn't uses multi-language -> " + tm.text);
						}

						if (bi.alignment == ButtonIndication.Alignment.LEFT)
						{
							tm.anchor = TextAnchor.MiddleRight;
							tm.alignment = TextAlignment.Right;
						}
					}
				}

				destGO.SetActive(false);
				tmpCom.DestObject = destGO;
				tmpCom.Offset = bi.indicationOffset;

				PrintInfoLog(tmpCom.Name + " line -> " + tmpCom.LineIndicator.name + " destObjName -> " + tmpCom.DestObject.name);
				compInd.Add(tmpCom);
			}
			else
			{
				PrintInfoLog("Neither " + partName + " or " + partName1 + " or " + partName2 + " is not in the model!");
			}
		}

		Emitter = null;
		if (basedOnEmitter)
		{
			WaveVR_RenderModel wrm = this.GetComponentInChildren<WaveVR_RenderModel>();

			if (wrm != null)
			{
				GameObject modelObj = wrm.gameObject;

				int modelchild = modelObj.transform.childCount;
				for (int j = 0; j < modelchild; j++)
				{
					GameObject childName = modelObj.transform.GetChild(j).gameObject;
					if (childName.name == "__CM__Emitter" || childName.name == "_[CM]_Emitter")
					{
						Emitter = childName;
					}
				}
			}
		}

		needRedraw = false;
	}
 public void getCountryandLanguage()
 {
     displayText      = "location country : " + rw.getSystemCountry() + " \nLanguage : " + rw.getSystemLanguage();
     displaytext.text = displayText;
 }
Example #8
0
    void Start()
    {
#if UNITY_EDITOR
        if (Application.isEditor)
        {
            return;
        }
#endif
        if (WaveVR.Instance == null)
        {
            Log.w(LOG_TAG, "Fail to initialize!");
            return;
        }

        wvrRes = WaveVR_Resource.instance;

        if (wvrRes == null)
        {
            Log.w(LOG_TAG, "Failed to initial WaveVR Resource instance!");
        }
        else
        {
            string lang    = wvrRes.getSystemLanguage();
            string country = wvrRes.getSystemCountry();
            Log.d(LOG_TAG, "system default language is " + lang);
            Log.d(LOG_TAG, "system default country is " + country);

            GameObject rt = GameObject.Find("ReloadText");
            if (rt != null)
            {
                Text reloadText = rt.GetComponent <Text>();
                reloadText.text = wvrRes.getStringByLanguage("reload_scene", lang, country);
            }
            else
            {
                Log.w(LOG_TAG, "Could not find reload scene text game object!");
            }

            GameObject mt = GameObject.Find("MainText");
            if (mt != null)
            {
                Text mainText = mt.GetComponent <Text>();
                mainText.text = wvrRes.getStringByLanguage("main_menu", lang, country);
            }
            else
            {
                Log.w(LOG_TAG, "Could not find main menu text game object!");
            }

            GameObject prt = GameObject.Find("PermReqText");
            if (prt != null)
            {
                Text permReqText = prt.GetComponent <Text>();
                permReqText.text = wvrRes.getStringByLanguage("perm_req", lang, country);
            }
            else
            {
                Log.w(LOG_TAG, "Could not find perm req text game object!");
            }

            GameObject qt = GameObject.Find("QuitText");
            if (qt != null)
            {
                Text quitText = qt.GetComponent <Text>();
                quitText.text = wvrRes.getStringByLanguage("exit", lang, country);
            }
            else
            {
                Log.w(LOG_TAG, "Could not find exit text game object!");
            }
        }

        pmInstance = WaveVR_PermissionManager.instance;
        if (pmInstance != null)
        {
            StartCoroutine(checkPackageManagerStatus());
        }
    }
    void CreateLineAndText(List <AutoComponentsIndication> tmpComp)
    {
        if (tmpComp.Count == 0)
        {
            return;
        }

        Log.d(LOG_TAG, "CreateLineAndText");

        foreach (AutoComponentsIndication comp in tmpComp)
        {
            Quaternion spawnRot = Quaternion.identity;
            spawnRot = transform.rotation;

            // destObject :  instantiate indicator and fill in the text
            comp.destObject = null;
            Vector3 destPos = Vector3.zero;
            if (comp.alignment == AutoButtonIndication.Alignment.Right)
            {
                if (displayPlane == DisplayPlane.Button)
                {
                    destPos = transform.TransformPoint(new Vector3(comp.distanceBetweenButtonAndText, comp.sourceObject.transform.localPosition.y, comp.sourceObject.transform.localPosition.z));
                }
                else if (displayPlane == DisplayPlane.Button_Auto)
                {
                    destPos = transform.TransformPoint(new Vector3(comp.distanceBetweenButtonAndText, comp.sourceObject.transform.localPosition.y, comp.zValue));
                }
                else
                {
                    destPos = transform.TransformPoint(new Vector3(comp.distanceBetweenButtonAndText, displayPlaneY, comp.zValue));
                }
            }
            else
            {
                if (displayPlane == DisplayPlane.Button)
                {
                    destPos = transform.TransformPoint(new Vector3(-comp.distanceBetweenButtonAndText, comp.sourceObject.transform.localPosition.y, comp.sourceObject.transform.localPosition.z));
                }
                else if (displayPlane == DisplayPlane.Button_Auto)
                {
                    destPos = transform.TransformPoint(new Vector3(-comp.distanceBetweenButtonAndText, comp.sourceObject.transform.localPosition.y, comp.zValue));
                }
                else
                {
                    destPos = transform.TransformPoint(new Vector3(-comp.distanceBetweenButtonAndText, displayPlaneY, comp.zValue));
                }
            }

            GameObject destGO = Instantiate(indicatorPrefab, destPos, spawnRot);
            destGO.name             = comp.name + "Ind";
            destGO.transform.parent = comp.sourceObject.transform;

            int childC = destGO.transform.childCount;
            for (int i = 0; i < childC; i++)
            {
                GameObject c = destGO.transform.GetChild(i).gameObject;
                if (comp.alignment == AutoButtonIndication.Alignment.Left)
                {
                    float tx = c.transform.localPosition.x;
                    c.transform.localPosition = new Vector3(tx * (-1), c.transform.localPosition.y, c.transform.localPosition.z);
                }
                TextMesh     tm = c.GetComponent <TextMesh>();
                MeshRenderer mr = c.GetComponent <MeshRenderer>();

                if (tm == null)
                {
                    Log.i(LOG_TAG, " tm is null ");
                }
                if (mr == null)
                {
                    Log.i(LOG_TAG, " mr is null ");
                }

                if (tm != null && mr != null)
                {
                    tm.characterSize = textCharacterSize;
                    if (c.name != "Shadow")
                    {
                        mr.material.SetColor("_Color", textColor);
                    }
                    else
                    {
                        Log.d(LOG_TAG, " Shadow found ");
                    }
                    tm.fontSize = textFontSize;
                    if (comp.useMultiLanguage)
                    {
                        sysLang    = rw.getSystemLanguage();
                        sysCountry = rw.getSystemCountry();
                        Log.d(LOG_TAG, " System language is " + sysLang);
                        if (sysLang.StartsWith("zh"))
                        {
                            Log.d(LOG_TAG, " Chinese language");
                            tm.characterSize = zhCharactarSize;
                        }

                        // use default string - multi-language
                        if (comp.indicationText == "system")
                        {
                            tm.text = rw.getString(comp.indicationKey);
                            Log.i(LOG_TAG, " Name: " + destGO.name + " uses default multi-language -> " + tm.text);
                        }
                        else
                        {
                            tm.text = rw.getString(comp.indicationText);
                            if (tm.text == "")
                            {
                                tm.text = comp.indicationText;
                            }
                            Log.i(LOG_TAG, " Name: " + destGO.name + " uses custom multi-language -> " + tm.text);
                        }
                    }
                    else
                    {
                        if (comp.indicationText == "system")
                        {
                            tm.text = comp.indicationKey;
                        }
                        else
                        {
                            tm.text = comp.indicationText;
                        }

                        Log.i(LOG_TAG, " Name: " + destGO.name + " didn't uses multi-language -> " + tm.text);
                    }

                    if (comp.alignment == AutoButtonIndication.Alignment.Left)
                    {
                        tm.anchor    = TextAnchor.MiddleRight;
                        tm.alignment = TextAlignment.Right;
                    }
                }
            }

            destGO.SetActive(false);
            comp.destObject = destGO;

            // lineIndicator : instantiate line
            comp.lineIndicator = null;
            Vector3 linePos = Vector3.zero;
            if (comp.alignment == AutoButtonIndication.Alignment.Right)
            {
                linePos = transform.TransformPoint(new Vector3(comp.sourceObject.transform.localPosition.x + comp.distanceBetweenButtonAndLine, comp.sourceObject.transform.localPosition.y, comp.sourceObject.transform.localPosition.z));
            }
            else if (comp.alignment == AutoButtonIndication.Alignment.Left)
            {
                linePos = transform.TransformPoint(new Vector3(comp.sourceObject.transform.localPosition.x - comp.distanceBetweenButtonAndLine, comp.sourceObject.transform.localPosition.y, comp.sourceObject.transform.localPosition.z));
            }

            // Create line
            GameObject lineGO = Instantiate(linePrefab, linePos, spawnRot);
            lineGO.name             = comp.name + "Line";
            lineGO.transform.parent = comp.sourceObject.transform;

            float tmpLength = Vector3.Distance(comp.sourceObject.transform.position, comp.destObject.transform.position) + comp.lineLengthAdjustment;
            if (tmpLength < 0)
            {
                tmpLength = 0;
            }

            var li = lineGO.GetComponent <IndicatorLine>();
            li.autoLayout    = autoLayout;
            li.lineColor     = lineColor;
            li.lineLength    = tmpLength;
            li.startWidth    = lineStartWidth;
            li.endWidth      = lineEndWidth;
            li.autoAlignment = comp.alignment;
            li.updateMeshSettings();

            Vector3 dir = comp.destObject.transform.position - comp.sourceObject.transform.position;

            Quaternion tmp = Quaternion.LookRotation(dir, transform.up);
            if (comp.alignment == AutoButtonIndication.Alignment.Right)
            {
                lineGO.transform.rotation = tmp * Quaternion.AngleAxis(-90, new Vector3(0, 1, 0));
            }
            else
            {
                lineGO.transform.rotation = tmp * Quaternion.AngleAxis(90, new Vector3(0, 1, 0));
            }

            lineGO.SetActive(false);
            comp.lineIndicator = lineGO;
        }
    }
Example #10
0
    // Use this for initialization
    void Start()
    {
        Log.d(LOG_TAG, "start()");
        rw = WaveVR_Resource.instance;

        Log.d(LOG_TAG, "system default language is " + rw.getSystemLanguage());
        Log.d(LOG_TAG, "system default country is " + rw.getSystemCountry());

        Log.d(LOG_TAG, "get string by system default language");

        string tmp = rw.getString("allow");

        Log.d(LOG_TAG, "get allow by system default language : " + tmp);

        tmp = rw.getString("demo");
        Log.d(LOG_TAG, "get demo by system default language : " + tmp);

        tmp = rw.getString("reject");
        Log.d(LOG_TAG, "get reject by system default language : " + tmp);

        tmp = rw.getString("test");
        Log.d(LOG_TAG, "get test by system default language : " + tmp);

        bool ret = rw.setPreferredLanguage("zh", "CN");

        Log.d(LOG_TAG, "set preferred lanuage to simplized chinese and get string = " + ret);

        tmp = rw.getString("allow");
        Log.d(LOG_TAG, "get allow by preferred lanuage(zhCN) : " + tmp);

        tmp = rw.getString("demo");
        Log.d(LOG_TAG, "get demo by preferred language(zhCN) : " + tmp);

        tmp = rw.getString("reject");
        Log.d(LOG_TAG, "get reject by preferred language(zhCN) : " + tmp);

        tmp = rw.getString("test");
        Log.d(LOG_TAG, "get test by preferred language(zhCN) : " + tmp);

        Log.d(LOG_TAG, "get string in dedicated language");
        tmp = rw.getStringByLanguage("demo", "zh", "TW");
        Log.d(LOG_TAG, "get demo by zhTW : " + tmp);
        tmp = rw.getStringByLanguage("demo", "en", "US");
        Log.d(LOG_TAG, "get demo by enUS : " + tmp);
        tmp = rw.getStringByLanguage("demo", "ja", "JP");
        Log.d(LOG_TAG, "get demo by jaJP : " + tmp);
        rw.getStringByLanguage("demo", "xx", "xx");
        Log.d(LOG_TAG, "get demo by xxxx: " + tmp);

        Log.d(LOG_TAG, "set back to default language ");
        rw.useSystemLanguage();

        tmp = rw.getString("allow");
        Log.d(LOG_TAG, "get allow from native : " + tmp);

        tmp = rw.getString("demo");
        Log.d(LOG_TAG, "get demo from native : " + tmp);

        tmp = rw.getString("reject");
        Log.d(LOG_TAG, "get reject from native : " + tmp);

        tmp = rw.getString("test");
        Log.d(LOG_TAG, "get test from native : " + tmp);
    }
Example #11
0
    void Start()
    {
#if UNITY_EDITOR
        if (Application.isEditor)
        {
            return;
        }
#endif
        if (WaveVR.Instance == null)
        {
            Log.w(LOG_TAG, "Fail to initialize!");
            return;
        }

        wvrRes = WaveVR_Resource.instance;

        if (wvrRes == null)
        {
            Log.w(LOG_TAG, "Failed to initial WaveVR Resource instance!");
        }
        else
        {
            string lang    = wvrRes.getSystemLanguage();
            string country = wvrRes.getSystemCountry();
            Log.d(LOG_TAG, "system default language is " + lang);
            Log.d(LOG_TAG, "system default country is " + country);

            GameObject ht = GameObject.Find("SixDoFHText");
            if (ht != null)
            {
                Text htText = ht.GetComponent <Text>();
                htText.text = wvrRes.getStringByLanguage("sixdof_head", lang, country);
            }
            else
            {
                Log.w(LOG_TAG, "Could not find 6dof head text game object!");
            }

            GameObject gt = GameObject.Find("SixDoFGText");
            if (gt != null)
            {
                Text gtText = gt.GetComponent <Text>();
                gtText.text = wvrRes.getStringByLanguage("sixdof_ground", lang, country);
            }
            else
            {
                Log.w(LOG_TAG, "Could not find 6dof ground text game object!");
            }

            GameObject qt = GameObject.Find("QuitText");
            if (qt != null)
            {
                Text quitText = qt.GetComponent <Text>();
                quitText.text = wvrRes.getStringByLanguage("exit", lang, country);
            }
            else
            {
                Log.w(LOG_TAG, "Could not find exit text game object!");
            }
        }

        int    dof           = WaveVR.Instance.is6DoFTracking();
        Button Btn6DoFHead   = GameObject.Find("Btn6DoFHead").GetComponent <Button>();
        Button Btn6DoFGround = GameObject.Find("Btn6DoFGround").GetComponent <Button>();

        switch (dof)
        {
        case 3: {
            if (Btn6DoFHead != null)
            {
                Btn6DoFHead.interactable = false;
            }
            if (Btn6DoFGround != null)
            {
                Btn6DoFGround.interactable = false;
            }
        }
        break;

        case 6: {
            if (Btn6DoFHead != null)
            {
                Btn6DoFHead.interactable = true;
            }
            if (Btn6DoFGround != null)
            {
                Btn6DoFGround.interactable = true;
            }
        }
        break;

        default:
            break;
        }
    }