//====================================== // Restore stored data from temp values //====================================== private void RestoreDatas() { GameObject activeGO = Selection.activeGameObject; titleWindow = tmp_titleWindow; FloatingBarVariableController activeGO_parentFbvc = activeGO.GetComponentInParent <FloatingBarVariableController>(); FloatingBarController activeGO_fbc = activeGO.GetComponent <FloatingBarController>(); activeGO_fbc.resource = resourceVariable = tmp_resourceVariable; activeGO_fbc.Min = minResourceVariable = tmp_minResourceVariable; activeGO_fbc.Max = maxResourceVariable = tmp_maxResourceVariable; activeGO_parentFbvc.RegenRate = regenRate = tmp_regenRate; RectTransform activeGO_transform = activeGO_fbc.GetComponent <RectTransform>(); // We can't change x, y, z values alone activeGO_transform.position = new Vector3(tmp_posX, tmp_posY, tmp_posZ); posX = tmp_posX; posY = tmp_posY; posZ = tmp_posZ; Image activeGO_fgdImage = activeGO.GetComponentsInChildren <Image>()[0]; Image activeGO_bgdImage = activeGO.GetComponentsInChildren <Image>()[1]; activeGO_bgdImage.color = positiveColor = tmp_positiveColor; activeGO_fgdImage.color = negativeColor = tmp_negativeColor; activeGO_bgdImage.sprite = positiveImage = tmp_positiveImage; activeGO_fgdImage.sprite = negativeImage = tmp_negativeImage; }
//================================= // Add loaded datas to temp values //================================= private static void SaveDatas() { // get values from object GameObject activeGO = Selection.activeGameObject; tmp_titleWindow = titleWindow = activeGO.name; FloatingBarVariableController activeGO_parentFbvc = activeGO.GetComponentInParent <FloatingBarVariableController>(); targettedGameObject = activeGO_parentFbvc.gameObject; FloatingBarController activeGO_fbc = activeGO.GetComponent <FloatingBarController>(); tmp_resourceVariable = resourceVariable = activeGO_fbc.resource; tmp_minResourceVariable = minResourceVariable = activeGO_fbc.Min; tmp_maxResourceVariable = maxResourceVariable = activeGO_fbc.Max; tmp_regenRate = regenRate = activeGO_parentFbvc.RegenRate; RectTransform activeGO_transform = activeGO_fbc.GetComponent <RectTransform>(); tmp_posX = posX = activeGO_transform.position.x; tmp_posY = posY = activeGO_transform.position.y; tmp_posZ = posZ = activeGO_transform.position.z; Image activeGO_fgdImage = activeGO.GetComponentsInChildren <Image>()[0]; Image activeGO_bgdImage = activeGO.GetComponentsInChildren <Image>()[1]; tmp_positiveColor = positiveColor = activeGO_bgdImage.color; tmp_negativeColor = negativeColor = activeGO_fgdImage.color; tmp_positiveImage = positiveImage = activeGO_bgdImage.sprite; tmp_negativeImage = negativeImage = activeGO_fgdImage.sprite; }
//===================================================== // Only for EditMode, 'immediately' apply changes made //===================================================== private void ApplyModifications() { GameObject activeGO = Selection.activeGameObject; activeGO.name = titleWindow; FloatingBarVariableController activeGO_parentFbvc = activeGO.GetComponentInParent <FloatingBarVariableController>(); FloatingBarController activeGO_fbc = activeGO.GetComponent <FloatingBarController>(); activeGO_fbc.resource = resourceVariable; activeGO_fbc.Min = minResourceVariable; activeGO_fbc.Max = maxResourceVariable; activeGO_parentFbvc.RegenRate = regenRate; RectTransform activeGO_transform = activeGO_fbc.GetComponent <RectTransform>(); activeGO_transform.position = new Vector3(posX, posY, posZ); Image activeGO_fgdImage = activeGO.GetComponentsInChildren <Image>()[0]; Image activeGO_bgdImage = activeGO.GetComponentsInChildren <Image>()[1]; activeGO_bgdImage.color = positiveColor; activeGO_fgdImage.color = negativeColor; activeGO_bgdImage.sprite = positiveImage; activeGO_fgdImage.sprite = negativeImage; }