public static EnergyBar3DBase Create3DBar(EnergyBar3DBase.BarType type, MadPanel panel) {
     switch (type) {
         case EnergyBar3DBase.BarType.Filled:
             return FilledRenderer3DBuilder.Create(panel);
         case EnergyBar3DBase.BarType.Repeated:
             return RepeatRenderer3DBuilder.Create(panel);
         case EnergyBar3DBase.BarType.Sequence:
             return SequenceRenderer3DBuilder.Create(panel);
         case EnergyBar3DBase.BarType.Transform:
             return TransformRenderer3DBuilder.Create(panel);
         default:
             Debug.LogError("Unknown bar type: " + type);
             return null;
     }
         
 }
Beispiel #2
0
        // ===========================================================
        // Constructors (Including Static Constructors)
        // ===========================================================

        // ===========================================================
        // Getters / Setters
        // ===========================================================

        // ===========================================================
        // Methods for/from SuperClass/Interfaces
        // ===========================================================

        public virtual void OnEnable()
        {
            energyBarBase   = target as EnergyBarBase;
            energyBar3DBase = target as EnergyBar3DBase;

            textureMode = serializedObject.FindProperty("textureMode");

            atlas = serializedObject.FindProperty("atlas");
            atlasTexturesBackground = serializedObject.FindProperty("atlasTexturesBackground");
            atlasTexturesForeground = serializedObject.FindProperty("atlasTexturesForeground");

            texturesBackground = serializedObject.FindProperty("texturesBackground");
            texturesForeground = serializedObject.FindProperty("texturesForeground");
            premultipliedAlpha = serializedObject.FindProperty("premultipliedAlpha");

            pivot        = serializedObject.FindProperty("pivot");
            guiDepth     = serializedObject.FindProperty("guiDepth");
            anchorObject = serializedObject.FindProperty("anchorObject");
            anchorCamera = serializedObject.FindProperty("anchorCamera");
            anchorOffset = serializedObject.FindProperty("anchorOffset");
            anchor3d     = serializedObject.FindProperty("anchor3d");
            positionSizeFromTransform           = serializedObject.FindProperty("positionSizeFromTransform");
            positionSizeFromTransformNormalized = serializedObject.FindProperty("positionSizeFromTransformNormalized");
            resizeMode = serializedObject.FindProperty("resizeMode");

            labelEnabled            = serializedObject.FindProperty("labelEnabled");
            labelSkin               = serializedObject.FindProperty("labelSkin");
            labelPosition           = serializedObject.FindProperty("labelPosition");
            labelPositionNormalized = serializedObject.FindProperty("labelPositionNormalized");
            labelPivot              = serializedObject.FindProperty("labelPivot");
            labelFormat             = serializedObject.FindProperty("labelFormat");
            labelColor              = serializedObject.FindProperty("labelColor");
            labelOutlineEnabled     = serializedObject.FindProperty("labelOutlineEnabled");
            labelOutlineColor       = serializedObject.FindProperty("labelOutlineColor");

            labelFont  = serializedObject.FindProperty("labelFont");
            labelScale = serializedObject.FindProperty("labelScale");

            effectSmoothChange               = serializedObject.FindProperty("effectSmoothChange");
            effectSmoothChangeSpeed          = serializedObject.FindProperty("effectSmoothChangeSpeed");
            effectSmoothChangeDirection      = serializedObject.FindProperty("effectSmoothChangeDirection");
            effectSmoothChangeFinishedNotify = serializedObject.FindProperty("effectSmoothChangeFinishedNotify");

            smoothEffectAnimBool.valueChanged.AddListener(Repaint);
            smoothEffectAnimBool.value = effectSmoothChange.boolValue;
        }
        // ===========================================================
        // Constants
        // ===========================================================
        // ===========================================================
        // Methods
        // ===========================================================
        public static EnergyBar3DBase Create3DBar(EnergyBar3DBase.BarType type)
        {
            var panel = MadPanel.UniqueOrNull();
            if (panel == null) {
            EditorUtility.DisplayDialog("Not Initialized", "You have to initialize EBT first", "OK");
            MadInitTool.ShowWindow();
            return null;
            } else {
            switch (type) {
                case EnergyBar3DBase.BarType.Filled:
                    return FillRenderer3DBuilder.Create();
                case EnergyBar3DBase.BarType.Repeated:
                    return RepeatRenderer3DBuilder.Create();
                default:
                    Debug.LogError("Unknown bar type: " + type);
                    return null;
            }

            }
        }
    // ===========================================================
    // Constructors (Including Static Constructors)
    // ===========================================================

    // ===========================================================
    // Getters / Setters
    // ===========================================================

    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================
    
    public virtual void OnEnable() {
        energyBarBase = target as EnergyBarBase;
        energyBar3DBase = target as EnergyBar3DBase;
        
        textureMode = serializedObject.FindProperty("textureMode");
        
        atlas = serializedObject.FindProperty("atlas");
        atlasTexturesBackground = serializedObject.FindProperty("atlasTexturesBackground");
        atlasTexturesForeground = serializedObject.FindProperty("atlasTexturesForeground");
    
        texturesBackground = serializedObject.FindProperty("texturesBackground");
        texturesForeground = serializedObject.FindProperty("texturesForeground");
        premultipliedAlpha = serializedObject.FindProperty("premultipliedAlpha");
    
        pivot = serializedObject.FindProperty("pivot");
        guiDepth = serializedObject.FindProperty("guiDepth");
        anchorObject = serializedObject.FindProperty("anchorObject");
        anchorCamera = serializedObject.FindProperty("anchorCamera");
        anchorOffset = serializedObject.FindProperty("anchorOffset");
        anchor3d = serializedObject.FindProperty("anchor3d");
        positionSizeFromTransform = serializedObject.FindProperty("positionSizeFromTransform");
        positionSizeFromTransformNormalized = serializedObject.FindProperty("positionSizeFromTransformNormalized");
        resizeMode = serializedObject.FindProperty("resizeMode");
        
        labelEnabled = serializedObject.FindProperty("labelEnabled");
        labelSkin = serializedObject.FindProperty("labelSkin");
        labelPosition = serializedObject.FindProperty("labelPosition");
        labelPositionNormalized = serializedObject.FindProperty("labelPositionNormalized");
        labelPivot = serializedObject.FindProperty("labelPivot");
        labelFormat = serializedObject.FindProperty("labelFormat");
        labelColor = serializedObject.FindProperty("labelColor");
        labelOutlineEnabled = serializedObject.FindProperty("labelOutlineEnabled");
        labelOutlineColor = serializedObject.FindProperty("labelOutlineColor");
        
        labelFont = serializedObject.FindProperty("labelFont");
        labelScale = serializedObject.FindProperty("labelScale");
        
        effectSmoothChange = serializedObject.FindProperty("effectSmoothChange");
        effectSmoothChangeSpeed = serializedObject.FindProperty("effectSmoothChangeSpeed");
        effectSmoothChangeDirection = serializedObject.FindProperty("effectSmoothChangeDirection");
        effectSmoothChangeFinishedNotify = serializedObject.FindProperty("effectSmoothChangeFinishedNotify");

        smoothEffectAnimBool.valueChanged.AddListener(Repaint);
        smoothEffectAnimBool.value = effectSmoothChange.boolValue;
    }
//    private void AtlasTextures(ref SerializedProperty textures, string label) {
//        if (MadGUI.Foldout(label, true)) {
//            var list = new MadGUI.ArrayList<EnergyBar3DBase.AtlasTex>(textures, (property) => {
//                var spriteName = property.FindPropertyRelative("spriteGUID");
//                var color = property.FindPropertyRelative("color");
//                
//                AtlasTexture(spriteName, color);
//            });
//            
//            list.Draw();
//        }
//    }
    
    private EnergyBar3DBase.AtlasTex[] AtlasTextures(EnergyBar3DBase.AtlasTex[] textures, string label) {
        if (MadGUI.Foldout(label, true)) {
            var l = new List<EnergyBar3DBase.AtlasTex>();
            if (textures != null) {
                l.AddRange(textures);
            }
            
            var list = new MadGUI.ArrayList<EnergyBar3DBase.AtlasTex>(l, (item) => {
                var spriteGUID = item.spriteGUID;
                var color = item.color;
                
                EditorGUI.BeginChangeCheck();
                AtlasTexture(spriteGUID, ref color, (guid) => {
                    item.spriteGUID = guid;
                    EditorUtility.SetDirty(target);
                });
                if (EditorGUI.EndChangeCheck()) {
                    item.spriteGUID = spriteGUID;
                    item.color = color;
                    EditorUtility.SetDirty(target);
                }

                return item;
            });
            list.onAdd += (tex) => tex.color = Color.white;
            
            list.Draw();
            return l.ToArray();
        } else {
            return textures;
        }
    }
Beispiel #6
0
 void CopyEnergyBar() {
     var nEnergyBar = Instantiate(energyBar) as EnergyBar3DBase;
     nEnergyBar.transform.parent = energyBar.transform.parent;
     
     int w = width;
     int h = height;
     
     energyBar = nEnergyBar;
     
     // preserve NGUI width/height
     width = w;
     height = h;
 }
 public static void ShowWindow(EnergyBar3DBase.BarType barType) {
     var tool = EditorWindow.GetWindow<CreateMeshBarTool>(false, "Create Bar", true);
     tool.barType = barType;
 }