Exemplo n.º 1
0
    public static void Inspector( StarBurst sb)
    {
        EditorGUILayout.Space();

        // Color
        EditorGUI.BeginChangeCheck();
        Color color = EditorGUILayout.ColorField("Color",sb.material.GetColor( "_Color1"));
        if(EditorGUI.EndChangeCheck()){
            sb.material.SetColor("_Color1",color);
        }

        EditorGUI.BeginChangeCheck();
        color = EditorGUILayout.ColorField("Color",sb.material.GetColor( "_Color2"));
        if(EditorGUI.EndChangeCheck()){
            sb.material.SetColor("_Color2",color);
        }

        // Power
        EditorGUI.BeginChangeCheck();
        float power = EditorGUILayout.Slider("Power",sb.material.GetFloat( "_Power"),0,1);
        if(EditorGUI.EndChangeCheck()){
            sb.material.SetFloat("_Power",power);
        }

        Rect rect=EditorGUILayout.BeginVertical();
        rect.height = 82;
        rect.width = 82;
        Texture2D textureDif = (Texture2D)EditorGUI.ObjectField(rect,"",sb.material.GetTexture("_DiffuseMap"),typeof(Texture2D),false);
        if (textureDif != sb.material.GetTexture("_DiffuseMap")){
            sb.material.SetTexture( "_DiffuseMap",textureDif);
        }
        EditorGUILayout.EndVertical();
        GUILayout.Space(85);

        sb.SizeX = EditorGUILayout.Slider("Size X",sb.SizeX,0.0f,5000.0f);
        sb.SizeY = EditorGUILayout.Slider("Size Y",sb.SizeY,0.0f,5000.0f);

        sb.Rotation =  EditorGUILayout.Slider("Rotation",sb.Rotation,-180f,180f);
        EditorGUILayout.Space();

        // Position
        EditorGUI.BeginChangeCheck();
        sb.Longitude = EditorGUILayout.Slider("Longitude",sb.Longitude,-180f,180f);
        if (EditorGUI.EndChangeCheck()){
            GuiTools.SetSceneCamera( -sb.Latitude, sb.Longitude);
        }

        EditorGUI.BeginChangeCheck();
        sb.Latitude = EditorGUILayout.Slider("latitude",sb.Latitude,-90,90f);
        if (EditorGUI.EndChangeCheck()){
            GuiTools.SetSceneCamera( -sb.Latitude, sb.Longitude);
        }

        if (GUI.changed){
            EditorUtility.SetDirty( sb);
        }
    }
Exemplo n.º 2
0
    public static void StarburstProperties(StarBurst sb )
    {
        #region Header
        EditorGUILayout.BeginHorizontal();
        Color crossColor = Color.red;

        int width = Screen.width-90;
        if (sb.isWaitToDelte){
            crossColor= Color.white;
            width =  Screen.width-134;
        }

        // Delete
        if (GuiTools.Button("X",crossColor,19)){
            sb.isWaitToDelte = !sb.isWaitToDelte;
        }
        if (sb.isWaitToDelte){
            if (GuiTools.Button("Delete",Color.red,50)){
                DestroyImmediate( sb.gameObject );
                return;
            }
        }

        bool showProperties = GuiTools.ChildFoldOut( sb.inspectorShowProperties,"Starburst",new Color(183f/255f,230f/255f,252f/255f),width);
        if (showProperties !=sb.inspectorShowProperties){
            sb.inspectorShowProperties = showProperties;

            if (sb.inspectorShowProperties){
                GuiTools.SetSceneCamera( -sb.Latitude, sb.Longitude);
            }
        }

        GUI.backgroundColor = Color.green;
        if (GUILayout.Button (new GUIContent("S"),GUILayout.Width(19))){

            StarBurst[] starbursts = StarburstField.instance.GetComponentsInChildren<StarBurst>();
            int i=0;
            while (i<starbursts.Length){
                starbursts[i].inspectorShowProperties = false;
                i++;
            }

            sb.inspectorShowProperties = true;
            GuiTools.SetSceneCamera( -sb.Latitude, sb.Longitude);
            sb.inspectorShowProperties = true;
        }
        GUI.backgroundColor = Color.white;

        EditorGUILayout.EndHorizontal();
        #endregion

        #region treatment
        if (sb.inspectorShowProperties){
            EditorGUI.indentLevel++;
            StarburstInspector.Inspector( sb);
            EditorGUI.indentLevel--;
        }
        #endregion
    }