Example #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            height = baseHeight;
            EditorGUI.BeginProperty(position, label, property);
            Rect propertylabelRect = new Rect(position.x, position.y, position.width, height);

            EditorGUI.PropertyField(propertylabelRect, property, GUIContent.none);
            Texture2D t2d = TranslateImgSpecific(property.stringValue, XIHLanguage.cn);

            if (t2d != null)
            {
                GUI.Label(new Rect(position.x, position.y + height, t2d.width, t2d.height), t2d);
                height += t2d.height;
            }
            else
            {
                GUI.Label(new Rect(position.x, position.y + height, position.width, baseHeight), $"Resources/Sprite/Localization/{property.stringValue}_{XIHLanguage.cn} Pic is Not Exist");
                height += baseHeight;
            }
            t2d = TranslateImgSpecific(property.stringValue, XIHLanguage.zh_TW);
            if (t2d != null)
            {
                GUI.Label(new Rect(position.x, position.y + height, t2d.width, t2d.height), t2d);
                height += t2d.height;
            }
            else
            {
                GUI.Label(new Rect(position.x, position.y + height, position.width, baseHeight), $"Resources/Sprite/Localization/{property.stringValue}_{XIHLanguage.zh_TW} Pic is Not Exist");
                height += baseHeight;
            }
            t2d = TranslateImgSpecific(property.stringValue, XIHLanguage.en);
            if (t2d != null)
            {
                GUI.Label(new Rect(position.x, position.y + height, t2d.width, t2d.height), t2d);
                height += t2d.height;
            }
            else
            {
                GUI.Label(new Rect(position.x, position.y + height, position.width, baseHeight), $"Resources/Sprite/Localization/{property.stringValue}_{XIHLanguage.en} Pic is Not Exist");
                height += baseHeight;
            }
            if (GUI.Button(new Rect(position.x, position.y + height, position.width, baseHeight), new GUIContent("ReFresh")))
            {
                LocalizationImage lo = Selection.activeGameObject.GetComponent <LocalizationImage>();
                lo.DoTranslate(property.stringValue);
                EditorUtility.SetDirty(Selection.activeGameObject);
                //AssetDatabase.SaveAssets();
            }
            ;
            height += baseHeight;
            EditorGUI.EndProperty();
        }
Example #2
0
 public static void DoTranslate(this LocalizationImage self, string newRelativePath)
 {
     self.GetComponent <LocalizationImage>()?.DoTranslate(newRelativePath);
 }