Exemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        //Undo start..
        UndoManager.CheckUndo();

        //Show input dialogs for yoke.
        InputFoldOut = EditorGUILayout.Foldout(InputFoldOut, "Input");
        if (InputFoldOut)
        {
            //Call base class to draw some stuff..
            ShowInputAxisOptions("Yaw", targetRudderPedal.Controller);

            EditorGUILayout.Space();
        }

        ParametersFoldOut = EditorGUILayout.Foldout(ParametersFoldOut, "Parameters");
        if (ParametersFoldOut)
        {
            targetRudderPedal.TranslateAxis    = EditorGUILayout.Vector3Field("Translate Axis", targetRudderPedal.TranslateAxis);
            targetRudderPedal.DeflectionMeters = EditorGUILayout.FloatField("Deflection Meters", targetRudderPedal.DeflectionMeters);
        }

        //Undo end..
        UndoManager.CheckDirty();
        EditorUtility.SetDirty(targetRudderPedal);
    }
    public override void OnInspectorGUI()
    {
        //Undo start..
        UndoManager.CheckUndo();

        //Show input dialogs for yoke.
        InputFoldOut = EditorGUILayout.Foldout(InputFoldOut, "Input");
        if (InputFoldOut)
        {
            //Call base class to draw some stuff..
            ShowInputAxisOptions("Steer", targetSteerableNosewheel.Controller);

            EditorGUILayout.Space();
        }

        ParametersFoldOut = EditorGUILayout.Foldout(ParametersFoldOut, "Parameters");
        if (ParametersFoldOut)
        {
            targetSteerableNosewheel.MaxDeflectionDegrees = EditorGUILayout.FloatField("Max Deflection Degrees", targetSteerableNosewheel.MaxDeflectionDegrees);

            targetSteerableNosewheel.SteerAxis = EditorGUILayout.Vector3Field("Steer Axis", targetSteerableNosewheel.SteerAxis);

            targetSteerableNosewheel.Model = EditorGUILayout.ObjectField("Model", targetSteerableNosewheel.Model, typeof(UnityEngine.GameObject), true) as UnityEngine.GameObject;

            targetSteerableNosewheel.ModelRotationAxis = EditorGUILayout.Vector3Field("Model Rotation Axis", targetSteerableNosewheel.ModelRotationAxis);
        }

        //Undo end..
        UndoManager.CheckDirty();
        EditorUtility.SetDirty(targetSteerableNosewheel);
    }
Exemplo n.º 3
0
    public override void OnInspectorGUI()
    {
        //Undo start..
        UndoManager.CheckUndo();

        //Show input dialogs for yoke.
        InputFoldOut = EditorGUILayout.Foldout(InputFoldOut, "Input");
        if (InputFoldOut)
        {
            //Call base class to draw some stuff..
            ShowInputAxisOptions("Throttle", targetThrottleStick.Controller);

            EditorGUILayout.Space();
        }

        ParametersFoldOut = EditorGUILayout.Foldout(ParametersFoldOut, "Parameters");
        if (ParametersFoldOut)
        {
            targetThrottleStick.ThrottleAxis         = EditorGUILayout.Vector3Field("Throttle Axis", targetThrottleStick.ThrottleAxis);
            targetThrottleStick.MaxDeflectionDegrees = EditorGUILayout.FloatField("Max Deflection Degrees", targetThrottleStick.MaxDeflectionDegrees);
        }

        //Undo end..
        UndoManager.CheckDirty();
        EditorUtility.SetDirty(targetThrottleStick);
    }
Exemplo n.º 4
0
    public override void OnInspectorGUI()
    {
        //Undo start..
        UndoManager.CheckUndo();

        targetPropwash.PropWashSource   = EditorGUILayout.ObjectField("Propwash Source", targetPropwash.PropWashSource, typeof(Engine), true) as Engine;
        targetPropwash.PropWashStrength = EditorGUILayout.FloatField("Strength Multiplier", targetPropwash.PropWashStrength);

        AffectedSectionsFoldOut = EditorGUILayout.Foldout(AffectedSectionsFoldOut, "Affected Sections (Root outwards)");
        if (AffectedSectionsFoldOut)
        {
            if (null != targetPropwash.AffectedSections)
            {
                for (int i = 0; i < targetPropwash.AffectedSections.Length; i++)
                {
                    targetPropwash.AffectedSections[i] = EditorGUILayout.Toggle(i.ToString(), targetPropwash.AffectedSections[i]);
                }
            }
        }

        EditorGUILayout.Space();



        //User help....
        if (null == targetPropwash.PropWashSource)
        {
            EditorGUILayout.HelpBox("No prop wash source. This will do nothing!", MessageType.Error);
        }

        //Undo end..
        UndoManager.CheckDirty();
        EditorUtility.SetDirty(targetPropwash);
    }
Exemplo n.º 5
0
        override public void OnInspectorGUI()
        {
            undoManager.CheckUndo();     // Check undo BEFORE GUI code.

            src.sampleProperty1 = EditorGUILayout.TextField("Text", src.sampleProperty1);
            src.sampleProperty2 = EditorGUILayout.TextField("Text", src.sampleProperty2);
            src.sampleProperty3 = EditorGUILayout.TextField("Text", src.sampleProperty3);

            undoManager.CheckDirty();     // Check dirty  AFTER all GUI code.
        }
Exemplo n.º 6
0
    public override void OnInspectorGUI()
    {
        //Undo start..
        UndoManager.CheckUndo();

        targetWing.SectionCount = EditorGUILayout.IntSlider("Section Count", targetWing.SectionCount, 1, 10);

        EditorGUILayout.Space();

        float widthF       = targetWing.WingTipWidthZeroToOne * 100.0f;
        int   widthPercent = (int)widthF;

        widthPercent = EditorGUILayout.IntSlider("Wing Tip width", widthPercent, 0, 100);
        targetWing.WingTipWidthZeroToOne = ((float)widthPercent) / 100.0f;

        float sweepF       = targetWing.WingTipSweep * 100.0f;
        int   wingTipSweep = (int)sweepF;

        wingTipSweep            = EditorGUILayout.IntSlider("Wing Tip Sweep", wingTipSweep, -1000, 1000);
        targetWing.WingTipSweep = (float)wingTipSweep / 100.0f;

        float angleF       = targetWing.WingTipAngle;
        int   wingTipAngle = (int)angleF;

        wingTipAngle            = EditorGUILayout.IntSlider("Wing Tip Angle", wingTipAngle, -90, 90);
        targetWing.WingTipAngle = (float)wingTipAngle;

        EditorGUILayout.Space();

        targetWing.Aerofoil = EditorGUILayout.ObjectField("Aerofoil", targetWing.Aerofoil, typeof(Aerofoil), true) as Aerofoil;

        if (null != targetWing.Aerofoil)
        {
            targetWing.Aerofoil.CL = EditorGUILayout.CurveField("Cl", targetWing.Aerofoil.CL);
            targetWing.Aerofoil.CD = EditorGUILayout.CurveField("Cd", targetWing.Aerofoil.CD);
            targetWing.Aerofoil.CM = EditorGUILayout.CurveField("Cm", targetWing.Aerofoil.CM);
        }
        else
        {
            EditorGUILayout.Space();

            EditorGUILayout.HelpBox("No aerofoil selected using basic lift drag equations.", MessageType.Warning);
            targetWing.CDOverride = EditorGUILayout.FloatField("CD Override", targetWing.CDOverride);
        }

        //Undo end..
        UndoManager.CheckDirty();
        EditorUtility.SetDirty(targetWing);
    }
    public override void OnInspectorGUI()
    {
        //Undo start..
        UndoManager.CheckUndo();

        //Show input dialogs for yoke.
        InputFoldOut = EditorGUILayout.Foldout(InputFoldOut, "Input");
        if (InputFoldOut)
        {
            //Call base class to draw some stuff..
            ShowInputButtonOptions("Toggle Landing Gear", targetLandingGear.LandingGearController);

            EditorGUILayout.Space();
        }

        base.OnInspectorGUI();

        //Undo end..
        UndoManager.CheckDirty();
        EditorUtility.SetDirty(targetLandingGear);
    }
Exemplo n.º 8
0
        protected virtual void DrawingStack(FTail_AnimatorBase tail)
        {
            if (drawDefaultInspector)
            {
                GUILayout.Space(5f);
                DrawDefaultInspector();
            }
            else
            {
                undoManager.CheckUndo();
                serializedObject.Update();

                GUILayout.Space(3f);

                EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                DrawTailList(tail);

                DrawSpeedSliders(tail);

                DrawTuningParameters(tail);

                EditorGUILayout.EndVertical();

                if (drawGizmoSwitcher)
                {
                    DrawBottomTailBreakLine();
                }

                if (GUI.changed)
                {
                    tail.OnValidate();
                }

                undoManager.CheckDirty();
                serializedObject.ApplyModifiedProperties();
            }
        }
Exemplo n.º 9
0
    static void GUIStart(IHOTweenPanel panel, HOEditorUndoManager undoManager, int labelsWidth, int fieldsWidth)
    {
        HOTweenEditorGUI.panel       = panel;
        HOTweenEditorGUI.undoManager = undoManager;
        HOTweenEditorGUI.labelsWidth = labelsWidth;
        HOTweenEditorGUI.fieldsWidth = fieldsWidth;
        undoManager.CheckUndo();
        EditorGUIUtility.LookLikeControls(labelsWidth, fieldsWidth);

        if (pluginDatas == null)
        {
            ReflectHOTween();
        }
        dcPropDataToValidPluginDatas = new Dictionary <HOTweenManager.HOPropData, List <PluginData> >();
        dcPropDataToValidPluginsEnum = new Dictionary <HOTweenManager.HOPropData, string[]>();
        foreach (HOTweenManager.HOTweenData twData in src.tweenDatas)
        {
            foreach (HOTweenManager.HOPropData propData in twData.propDatas)
            {
                StoreValidPluginsFor(twData.targetType, propData);
            }
        }
    }
Exemplo n.º 10
0
 public override void OnInspectorGUI()
 {
     newFocusedControl = GUI.GetNameOfFocusedControl();
     um.CheckUndo();
     // if(useFormulae) {
     //  GUILayout.BeginHorizontal();
     //  GUILayout.Label("Formulae", GUILayout.Width(60));
     //  GUI.enabled=false;
     //  EditorGUILayout.TextField(fdb == null ? "null" : AssetDatabase.GetAssetPath(fdb));
     //  GUI.enabled=true;
     //  GUILayout.EndHorizontal();
     // }
     OnSRPGCKInspectorGUI();
     guiChangedAtAll = guiChangedAtAll || GUI.changed;
     um.CheckDirty();
     lastFocusedControl = newFocusedControl;
     if (guiChangedAtAll &&
         EditorApplication.isPlayingOrWillChangePlaymode)
     {
         // Debug.Log("save before playmode change");
         SaveAsset();
     }
 }
Exemplo n.º 11
0
    public override void OnInspectorGUI()
    {
        //Undo start..
        UndoManager.CheckUndo();

        //Show input dialogs for yoke.
        InputFoldOut = EditorGUILayout.Foldout(InputFoldOut, "Input");
        if (InputFoldOut)
        {
            //Call base class to draw some stuff..
            ShowInputAxisOptions("Pitch", targetYoke.PitchController);

            EditorGUILayout.Space();

            ShowInputAxisOptions("Roll", targetYoke.RollController);

            EditorGUILayout.Space();
        }


        ParametersFoldOut = EditorGUILayout.Foldout(ParametersFoldOut, "Parameters");
        if (ParametersFoldOut)
        {
            targetYoke.PitchAxis = EditorGUILayout.Vector3Field("Pitch Axis", targetYoke.PitchAxis);
            targetYoke.MaxPitchTranslationMeters = EditorGUILayout.FloatField("Max Pitch Translation Meters", targetYoke.MaxPitchTranslationMeters);

            EditorGUILayout.Space();

            targetYoke.RollAxis = EditorGUILayout.Vector3Field("Roll Axis", targetYoke.RollAxis);
            targetYoke.MaxRollDeflectionDegrees = EditorGUILayout.FloatField("Max Roll Deflection Degrees", targetYoke.MaxRollDeflectionDegrees);
        }


        //Undo end..
        UndoManager.CheckDirty();
        EditorUtility.SetDirty(targetYoke);
    }
Exemplo n.º 12
0
    public override void OnInspectorGUI()
    {
        //Undo start..
        UndoManager.CheckUndo();

        if (GUILayout.Button("Get latest version of UnityFS."))
        {
            FetchVersion = true;
        }

        //Show input dialogs for camera change.
        InputFoldOut = EditorGUILayout.Foldout(InputFoldOut, "Input");
        if (InputFoldOut)
        {
            ShowInputButtonOptions("Change Camera", targetAircraft.ChangeCameraController);
            EditorGUILayout.Space();
        }

        base.OnInspectorGUI();

        //Undo end..
        UndoManager.CheckDirty();
        EditorUtility.SetDirty(targetAircraft);
    }
Exemplo n.º 13
0
    static void GUIStart(IHOTweenPanel panel, HOEditorUndoManager undoManager, int labelsWidth, int fieldsWidth)
    {
        HOTweenEditorGUI.panel = panel;
        HOTweenEditorGUI.undoManager = undoManager;
        HOTweenEditorGUI.labelsWidth = labelsWidth;
        HOTweenEditorGUI.fieldsWidth = fieldsWidth;
        undoManager.CheckUndo();
        EditorGUIUtility.LookLikeControls(labelsWidth, fieldsWidth);

        if (pluginDatas == null) ReflectHOTween();
        dcPropDataToValidPluginDatas = new Dictionary<HOTweenManager.HOPropData, List<PluginData>>();
        dcPropDataToValidPluginsEnum = new Dictionary<HOTweenManager.HOPropData, string[]>();
        foreach (HOTweenManager.HOTweenData twData in src.tweenDatas) {
            foreach (HOTweenManager.HOPropData propData in twData.propDatas) {
                StoreValidPluginsFor(twData.targetType, propData);
            }
        }
    }
Exemplo n.º 14
0
    void OnGUI()
    {
        if (EditorWindowUtility.ShowWindow())
        {
            if (smartLocWindow == null || thisCultureInfo == null)
            {
                this.Close();                // Temp fix
            }
            else if (!rootFileChanged)
            {
                undoManager.CheckUndo();
                GUILayout.Label("Language - " + thisLanguage, EditorStyles.boldLabel, GUILayout.Width(200));

                //Copy all the Base Values
                GUILayout.Label("If you want to copy all the base values from the root file", EditorStyles.miniLabel);
                if (GUILayout.Button("Copy All Base Values", GUILayout.Width(150)))
                {
                    int count = 0;
                    foreach (KeyValuePair <string, LocalizedObject> rootValue in rootValues)
                    {
                        if (rootValue.Value.ObjectType == LocalizedObjectType.STRING)
                        {
                            thisLanguageValues[count].changedValue.TextValue = rootValue.Value.TextValue;
                        }
                        count++;
                    }
                }

                GUILayout.Label("Microsoft Translator", EditorStyles.boldLabel);
                if (!smartLocWindow.MicrosoftTranslator.IsInitialized)
                {
                    GUILayout.Label("Microsoft Translator is not authenticated", EditorStyles.miniLabel);
                }
                else
                {
                    if (canLanguageBeTranslated)
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label("Translate From:", GUILayout.Width(100));
                        translateFromLanguageValue = EditorGUILayout.Popup(translateFromLanguageValue, availableTranslateLangEnglishNames);
                        EditorGUILayout.EndHorizontal();

                        if (oldTranslateFromLanguageValue != translateFromLanguageValue)
                        {
                            oldTranslateFromLanguageValue = translateFromLanguageValue;
                            //The value have been changed, load the language file of the other language that you want to translate from
                            //I load it like this to show the translate buttons only on the ones that can be translated i.e some values
                            //in the "from" language could be an empty string - no use in translating that
                            if (translateFromDictionary != null)
                            {
                                translateFromDictionary.Clear();
                                translateFromDictionary = null;
                            }
                            if (translateFromLanguageValue != 0)
                            {
                                string englishName = availableTranslateLangEnglishNames[translateFromLanguageValue];
                                foreach (CultureInfo info in availableTranslateFromLanguages)
                                {
                                    if (info.EnglishName == englishName)
                                    {
                                        translateFromDictionary = LocFileUtility.LoadParsedLanguageFile(info.Name);
                                        translateFromLanguage   = info.Name;
                                        break;
                                    }
                                }
                            }
                        }

                        //Translate all the available keys
                        if (translateFromLanguageValue != 0 && GUILayout.Button("Translate all text", GUILayout.Width(150)))
                        {
                            List <string> keys             = new List <string>();
                            List <string> textsToTranslate = new List <string>();
                            int           characterCount   = 0;
                            foreach (KeyValuePair <string, LocalizedObject> stringPair in translateFromDictionary)
                            {
                                if (stringPair.Value.ObjectType == LocalizedObjectType.STRING &&
                                    stringPair.Value.TextValue != null && stringPair.Value.TextValue != "")
                                {
                                    int textLength = stringPair.Value.TextValue.Length;
                                    //Microsoft translator only support translations below 1000 character
                                    //I'll cap it to 700, which gives 300 extra if the translated value is longer
                                    if (textLength < 700)
                                    {
                                        characterCount += textLength;
                                        keys.Add(stringPair.Key);
                                        textsToTranslate.Add(stringPair.Value.TextValue);
                                    }
                                }

                                //Microsoft translator only support translations with 100 array values and a total
                                // character cap of 10000,
                                // I'll cap it to 7000, which gives 3000 extra if the translated value is longer
                                if (keys.Count >= 99 || characterCount >= 7000)
                                {
                                    //Create a new reference to the list with keys, because we need it non-cleared in the callback
                                    List <string> keysToSend = new List <string>();
                                    keysToSend.AddRange(keysToSend.ToArray());

                                    //Send the values
                                    smartLocWindow.MicrosoftTranslator.TranslateArray(textsToTranslate, translateFromLanguage,
                                                                                      thisCultureInfo.Name, keysToSend, new TranslateCompleteArrayCallback(TranslatedTextArrayCompleted));

                                    //Reset values
                                    characterCount = 0;
                                    keys.Clear();
                                    textsToTranslate.Clear();
                                }
                            }
                            if (keys.Count != 0)
                            {
                                smartLocWindow.MicrosoftTranslator.TranslateArray(textsToTranslate, translateFromLanguage,
                                                                                  thisCultureInfo.Name, keys, new TranslateCompleteArrayCallback(TranslatedTextArrayCompleted));

                                //Reset values
                                characterCount = 0;
                                keys.Clear();
                                textsToTranslate.Clear();
                            }
                        }
                    }
                    else
                    {
                        GUILayout.Label(thisCultureInfo.EnglishName + " is not available for translation", EditorStyles.miniLabel);
                    }
                }

                GUILayout.Label("Language Values", EditorStyles.boldLabel);
                //Search field
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Search for Key:", GUILayout.Width(100));
                searchText = EditorGUILayout.TextField(searchText);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Key", EditorStyles.boldLabel, GUILayout.Width(120));
                GUILayout.Label("Base Value", EditorStyles.boldLabel, GUILayout.Width(120));
                GUILayout.Label("Copy Base", EditorStyles.miniLabel, GUILayout.Width(70));
                if (canLanguageBeTranslated)
                {
                    //TODO::Change to small picture
                    GUILayout.Label("T", EditorStyles.miniLabel, GUILayout.Width(20));
                }
                GUILayout.Label(thisLanguage + " Value", EditorStyles.boldLabel);
                EditorGUILayout.EndHorizontal();

                //Check if the user searched for a value
                bool didSearch = false;
                if (searchText != "")
                {
                    didSearch = true;
                    GUILayout.Label("Search Results - \"" + searchText + "\":", EditorStyles.boldLabel);
                }

                //Start the scroll view
                scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
                int iterationCount = 0;
                foreach (KeyValuePair <string, LocalizedObject> rootValue in rootValues)
                {
                    if (didSearch)
                    {
                        //If the name of the key doesn't contain the search value, then skip a value
                        if (!rootValue.Key.ToLower().Contains(searchText.ToLower()))
                        {
                            continue;
                        }
                    }

                    if (rootValue.Value.ObjectType == LocalizedObjectType.STRING)
                    {
                        OnTextFieldGUI(rootValue, iterationCount);
                    }
                    else if (rootValue.Value.ObjectType == LocalizedObjectType.AUDIO)
                    {
                        OnAudioGUI(rootValue, iterationCount);
                    }
                    else if (rootValue.Value.ObjectType == LocalizedObjectType.GAME_OBJECT)
                    {
                        OnGameObjectGUI(rootValue, iterationCount);
                    }
                    else if (rootValue.Value.ObjectType == LocalizedObjectType.TEXTURE)
                    {
                        OnTextureGUI(rootValue, iterationCount);
                    }

                    iterationCount++;
                }
                //End the scroll view
                EditorGUILayout.EndScrollView();

                if (guiChanged)
                {
                    GUILayout.Label("- You have unsaved changes", EditorStyles.miniLabel);
                }

                //If any changes to the gui is made
                if (GUI.changed)
                {
                    guiChanged = true;
                }

                GUILayout.Label("Save Changes", EditorStyles.boldLabel);
                GUILayout.Label("Remember to always press save when you have changed values", EditorStyles.miniLabel);
                if (GUILayout.Button("Save/Rebuild"))
                {
                    //Copy everything into a dictionary
                    Dictionary <string, string> newLanguageValues = new Dictionary <string, string>();
                    foreach (SerializableLocalizationObjectPair objectPair in this.thisLanguageValues)
                    {
                        if (objectPair.changedValue.ObjectType == LocalizedObjectType.STRING)
                        {
                            newLanguageValues.Add(objectPair.changedValue.GetFullKey(objectPair.keyValue), objectPair.changedValue.TextValue);
                        }
                        else
                        {
                            //Delete the file in case there was a file there previously
                            LocFileUtility.DeleteFileFromResources(objectPair.changedValue.GetFullKey(objectPair.keyValue), thisCultureInfo);

                            //Store the path to the file
                            string pathValue = LocFileUtility.CopyFileIntoResources(objectPair, thisCultureInfo);
                            newLanguageValues.Add(objectPair.changedValue.GetFullKey(objectPair.keyValue), pathValue);
                        }
                    }
                    LocFileUtility.SaveLanguageFile(newLanguageValues, LocFileUtility.rootLanguageFilePath + "." + thisCultureInfo.Name + LocFileUtility.resXFileEnding);
                    guiChanged = false;
                }

                undoManager.CheckDirty();
            }
            else
            {
                //The root file did change, which means that you have to reload. A key might have changed
                //We can't have language files with different keys
                GUILayout.Label("The root file might have changed", EditorStyles.boldLabel);
                GUILayout.Label("The root file did save, which means that you have to reload. A key might have changed.", EditorStyles.miniLabel);
                GUILayout.Label("You can't have language files with different keys", EditorStyles.miniLabel);
                if (GUILayout.Button("Reload Language File"))
                {
                    InitializeLanguage(thisCultureInfo, LocFileUtility.LoadParsedLanguageFile(null), LocFileUtility.LoadParsedLanguageFile(thisCultureInfo.Name));
                }
            }
        }
    }
Exemplo n.º 15
0
    public override void OnInspectorGUI()
    {
        //Undo start..
        UndoManager.CheckUndo();

        //Show input dialogs for yoke.
        InputFoldOut = EditorGUILayout.Foldout(InputFoldOut, "Input");
        if (InputFoldOut)
        {
            //Call base class to draw some stuff..
            ShowInputAxisOptions("Throttle", targetEngine.ThrottleController);

            EditorGUILayout.Space();

            ShowInputButtonOptions("Engine", targetEngine.EngineStartController);

            EditorGUILayout.Space();
        }

        PropFoldOut = EditorGUILayout.Foldout(PropFoldOut, "Propeller");
        if (PropFoldOut)
        {
            targetEngine.AnimatedPropellerPivot = EditorGUILayout.ObjectField("Animated Pivot", targetEngine.AnimatedPropellerPivot, typeof(UnityEngine.Transform), true) as UnityEngine.Transform;

            targetEngine.AnimatedPropellerPivotRotateAxis = EditorGUILayout.Vector3Field("Rotate Axis", targetEngine.AnimatedPropellerPivotRotateAxis);

            targetEngine.SlowPropeller = EditorGUILayout.ObjectField("Slow Propeller", targetEngine.SlowPropeller, typeof(UnityEngine.GameObject), true) as UnityEngine.GameObject;

            targetEngine.FastPropeller = EditorGUILayout.ObjectField("Fast Propeller", targetEngine.FastPropeller, typeof(UnityEngine.GameObject), true) as UnityEngine.GameObject;

            targetEngine.RPMToUseFastProp = EditorGUILayout.FloatField("RPM To Switch To Fast Prop", targetEngine.RPMToUseFastProp);

            EditorGUILayout.Space();
        }

        EngineFoldOut = EditorGUILayout.Foldout(EngineFoldOut, "Engine");
        if (EngineFoldOut)
        {
            targetEngine.CurrentEngineState = (Engine.EngineState)EditorGUILayout.EnumPopup("Current Engine State", targetEngine.CurrentEngineState);

            targetEngine.IdleRPM = EditorGUILayout.FloatField("Idle RPM", targetEngine.IdleRPM);

            targetEngine.MaxRPM = EditorGUILayout.FloatField("Max RPM", targetEngine.MaxRPM);

            targetEngine.ForceAtMaxRPM = EditorGUILayout.FloatField("Force At Max RPM", targetEngine.ForceAtMaxRPM);

            targetEngine.PercentageForceAppliedVSAirspeedKTS = EditorGUILayout.CurveField("Percentage Force Applied VS Airspeed KTS", targetEngine.PercentageForceAppliedVSAirspeedKTS);

            targetEngine.RPMToAddPerKTOfSpeed = EditorGUILayout.FloatField("RPM To Add Per Knot Of Speed", targetEngine.RPMToAddPerKTOfSpeed);

            targetEngine.RPMLerpSpeed = EditorGUILayout.FloatField("RPM Lerp Speed", targetEngine.RPMLerpSpeed);

            EditorGUILayout.Space();
        }

        AudioFoldOut = EditorGUILayout.Foldout(AudioFoldOut, "Audio");
        if (AudioFoldOut)
        {
            targetEngine.EngineStartClip = EditorGUILayout.ObjectField("Engine Start Clip", targetEngine.EngineStartClip, typeof(UnityEngine.AudioClip), true) as UnityEngine.AudioClip;

            targetEngine.EngineRunClip = EditorGUILayout.ObjectField("Engine Run Clip", targetEngine.EngineRunClip, typeof(UnityEngine.AudioClip), true) as UnityEngine.AudioClip;

            targetEngine.PitchAtIdleRPM = EditorGUILayout.FloatField("Pitch At Idle RPM", targetEngine.PitchAtIdleRPM);

            targetEngine.PitchAtMaxRPM = EditorGUILayout.FloatField("Pitch At Max RPM", targetEngine.PitchAtMaxRPM);

            EditorGUILayout.Space();
        }

        //Undo end..
        UndoManager.CheckDirty();
        EditorUtility.SetDirty(targetEngine);
    }
Exemplo n.º 16
0
	static void GUIStart(IHOTweenPanel panel, HOEditorUndoManager undoManager, int labelsWidth, int fieldsWidth)
	{
        _hiliteStyle = new GUIStyle(HOGUIStyle.toolbarTextField);
        _hiliteStyle.SetFontColor(new Color(0.8f, 0.55f, 0f));
        _idButtonStyle = new GUIStyle(HOGUIStyle.toolbarButton);
        _idButtonStyle.alignment = TextAnchor.MiddleLeft;
        _idMissingButtonStyle = new GUIStyle(_idButtonStyle);
        _idButtonStyle.SetFontColor(new Color(0.8f, 0.55f, 0f));
        _idMissingButtonStyle.fontStyle = FontStyle.Italic;

		HOTweenEditorGUI.panel = panel;
		HOTweenEditorGUI.undoManager = undoManager;
		HOTweenEditorGUI.labelsWidth = labelsWidth;
		HOTweenEditorGUI.fieldsWidth = fieldsWidth;
		undoManager.CheckUndo();
		EditorGUIUtility.LookLikeControls(labelsWidth, fieldsWidth);

		if (pluginDatas == null) ReflectHOTween();
		dcPropDataToValidPluginDatas = new Dictionary<HOTweenManager.HOPropData, List<PluginData>>();
		dcPropDataToValidPluginsEnum = new Dictionary<HOTweenManager.HOPropData, string[]>();
		foreach (HOTweenManager.HOTweenData twData in src.tweenDatas) {
			foreach (HOTweenManager.HOPropData propData in twData.propDatas) {
				StoreValidPluginsFor(twData.targetType, propData);
			}
		}
	}
    void OnGUI()
    {
        undoManager.CheckUndo();

        GUILayout.Label("Export Settings", EditorStyles.boldLabel);
        assetBundleFolderLocation = EditorGUILayout.TextField("AssetBundles folder", assetBundleFolderLocation);
        GUILayout.Label("Application.dataPath			 "+ Application.dataPath, EditorStyles.label);
        exportLocation      = EditorGUILayout.TextField("Export folder", exportLocation);
        bundleFileExtension = EditorGUILayout.TextField("Bundle file ext.", bundleFileExtension);
        setLowerCaseName    = EditorGUILayout.Toggle("Names to lower case", setLowerCaseName);

        buildAssetBundleOptions  = EditorGUILayout.BeginToggleGroup("BuildAssetBundleOptions", buildAssetBundleOptions);
        collectDependencies      = EditorGUILayout.Toggle("CollectDependencies", collectDependencies);
        completeAssets           = EditorGUILayout.Toggle("CompleteAssets", completeAssets);
        disableWriteTypeTree     = EditorGUILayout.Toggle("DisableWriteTypeTree", disableWriteTypeTree);
        deterministicAssetBundle = EditorGUILayout.Toggle("DeterministicAssetBundle", deterministicAssetBundle);
        uncompressedAssetBundle  = EditorGUILayout.Toggle("UncompressedAssetBundle", uncompressedAssetBundle);
        EditorGUILayout.EndToggleGroup();

        optionalSettings = EditorGUILayout.BeginToggleGroup("Optional Settings", optionalSettings);
        buildTarget      = (BuildTarget)EditorGUILayout.EnumPopup("Build Target", buildTarget);
        EditorGUILayout.EndToggleGroup();

        undoManager.CheckDirty();

        GUILayout.Label("Reset Settings", EditorStyles.boldLabel);
        if (GUILayout.Button("Reset"))
        {
            ClearPreferences(this);
            WriteEditorPrefs(this);
            CreateAssetBundles.ReadBundleControlFile(Application.dataPath + exportLocation + CreateAssetBundles.bundleControlFileName, bundleVersions);
            CreateAssetBundles.ReadBundleContentsFile(Application.dataPath + exportLocation + CreateAssetBundles.bundleContentsFileName, bundleContents);
            ReadBundleFileSizes();
        }

        GUILayout.Label("Build", EditorStyles.boldLabel);
        if (GUILayout.Button("Build Asset Bundles"))
        {
            if (!CreateAssetBundles.ExportAssetBundleFolders(this))
            {
                Debug.LogError("AssetBundle Build Failed! - Please check your settings in the Bundle Creator at Assets->Bundle Creator-> Asset Bundle Creator.");
            }
            else
            {
                //It worked, save the preferences and reload the control file
                WriteEditorPrefs(this);
                bundleVersions.Clear();
                bundleContents.Clear();
                bundleFileSizes.Clear();
                CreateAssetBundles.ReadBundleControlFile(Application.dataPath + exportLocation + CreateAssetBundles.bundleControlFileName, bundleVersions);
                CreateAssetBundles.ReadBundleContentsFile(Application.dataPath + exportLocation + CreateAssetBundles.bundleContentsFileName, bundleContents);
                ReadBundleFileSizes();
            }
        }

        GUILayout.Label("Bundle Versions", EditorStyles.boldLabel);
        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
        foreach (KeyValuePair <string, int> bundleVersion in bundleVersions)
        {
            float bundleFileSize = 0;
            bundleFileSizes.TryGetValue(bundleVersion.Key, out bundleFileSize);
            if (GUILayout.Button(bundleVersion.Key + ", Version:" + bundleVersion.Value + ", Size: " + bundleFileSize + "kb"))
            {
                List <string> assetsInBundle = null;
                bundleContents.TryGetValue(bundleVersion.Key, out assetsInBundle);
                if (assetsInBundle != null)
                {
                    CreateContentWindow();
                    contentWindow.SelectAssetBundle(bundleVersion.Key, assetsInBundle, Application.dataPath + exportLocation, bundleFileSize);
                    contentWindow.ShowTab();
                }
            }
        }
        EditorGUILayout.EndScrollView();
    }
    public override void OnInspectorGUI()
    {
        //Undo start..
        UndoManager.CheckUndo();

        InputFoldOut = EditorGUILayout.Foldout(InputFoldOut, "Input");
        if (InputFoldOut)
        {
            //Call base class to draw some stuff..
            ShowInputAxisOptions("Surface", targetControlSurface.Controller);

            targetControlSurface.InputCurve = EditorGUILayout.CurveField("Input Curve", targetControlSurface.InputCurve);

            //If input curve has no keyframes make some to ease user.
            if (0 == targetControlSurface.InputCurve.keys.Length)
            {
                targetControlSurface.InputCurve.AddKey(0.0f, 0.0f);
                targetControlSurface.InputCurve.AddKey(1.0f, 1.0f);
            }
        }

        EditorGUILayout.Space();

        ParametersFoldOut = EditorGUILayout.Foldout(ParametersFoldOut, "Parameters");
        if (ParametersFoldOut)
        {
            targetControlSurface.MaxDeflectionDegrees = EditorGUILayout.FloatField("Max Deflection Degrees", targetControlSurface.MaxDeflectionDegrees);

            int rootPercent = (int)(targetControlSurface.RootHingeDistanceFromTrailingEdge * 100.0f);
            rootPercent = EditorGUILayout.IntSlider("Root hinge offset", rootPercent, 0, 100);
            targetControlSurface.RootHingeDistanceFromTrailingEdge = (float)rootPercent / 100.0f;

            int tipPercent = (int)(targetControlSurface.TipHingeDistanceFromTrailingEdge * 100.0f);
            tipPercent = EditorGUILayout.IntSlider("Tip hinge offset", tipPercent, 0, 100);
            targetControlSurface.TipHingeDistanceFromTrailingEdge = (float)tipPercent / 100.0f;

            AffectedSectionsFoldOut = EditorGUILayout.Foldout(AffectedSectionsFoldOut, "Affected Sections (Root outwards)");
            if (AffectedSectionsFoldOut)
            {
                if (null != targetControlSurface.AffectedSections)
                {
                    for (int i = 0; i < targetControlSurface.AffectedSections.Length; i++)
                    {
                        targetControlSurface.AffectedSections[i] = EditorGUILayout.Toggle(i.ToString(), targetControlSurface.AffectedSections[i]);
                    }
                }
            }
        }

        EditorGUILayout.Space();

        VisualsFoldOut = EditorGUILayout.Foldout(VisualsFoldOut, "Visuals");
        if (VisualsFoldOut)
        {
            targetControlSurface.Model = EditorGUILayout.ObjectField("Model", targetControlSurface.Model, typeof(UnityEngine.GameObject), true) as UnityEngine.GameObject;

            if (targetControlSurface.Model)
            {
                targetControlSurface.ModelRotationAxis = EditorGUILayout.Vector3Field("Model Rotation Axis", targetControlSurface.ModelRotationAxis);
            }
        }


        //User help....
        if (targetControlSurface.Controller.AxisName.Length == 0)
        {
            EditorGUILayout.HelpBox("No input axis defined.", MessageType.Error);
        }

        if (!targetControlSurface.Model)
        {
            EditorGUILayout.HelpBox("No model attached for visual rotation.", MessageType.Warning);
        }


        //Undo end..
        UndoManager.CheckDirty();
        EditorUtility.SetDirty(targetControlSurface);
    }
Exemplo n.º 19
0
    void OnGUI()
    {
        if (EditorWindowUtility.ShowWindow())
        {
            GUILayout.Label("Settings", EditorStyles.boldLabel);
            if (!LocFileUtility.CheckIfRootLanguageFileExists())
            {
                if (GUILayout.Button("Create New Localization System"))
                {
                    LocFileUtility.CreateRootResourceFile();
                }
            }
            else
            {
                undoManager.CheckUndo();
                if (GUILayout.Button("Refresh"))
                {
                    LocFileUtility.CheckAvailableLanguages(availableLanguages, notAvailableLanguages, notAvailableLanguagesEnglishNames);
                }
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Microsoft Translator Settings", EditorStyles.boldLabel, GUILayout.Width(200));
                if (microsoftTranslator.IsInitialized)
                {
                    GUILayout.Label(" - Authenticated!", EditorStyles.miniLabel);
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Client ID:", GUILayout.Width(70));
                mtCliendID = EditorGUILayout.TextField(mtCliendID);
                GUILayout.Label("Client Secret:", GUILayout.Width(100));
                mtCliendSecret = EditorGUILayout.TextField(mtCliendSecret);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Save", GUILayout.Width(50)))
                {
                    SaveMicrosoftTranslatorSettings();
                    if (!microsoftTranslator.IsInitialized)
                    {
                        microsoftTranslator.GetAccessToken(mtCliendID, mtCliendSecret);
                    }
                }
                if (!microsoftTranslator.IsInitialized)
                {
                    if (GUILayout.Button("Authenticate!", GUILayout.Width(150)))
                    {
                        microsoftTranslator.GetAccessToken(mtCliendID, mtCliendSecret);
                    }
                }
                keepTranslatorAuthenticated = EditorGUILayout.Toggle("Keep Authenticated", keepTranslatorAuthenticated);
                EditorGUILayout.EndHorizontal();

                GUILayout.Label("Edit Root Language File", EditorStyles.boldLabel);
                if (GUILayout.Button("Edit"))
                {
                    ShowRootEditWindow(LocFileUtility.LoadParsedLanguageFile(null));
                }

                GUILayout.Label("Create new language", EditorStyles.boldLabel);
                chosenCreateNewCultureValue = EditorGUILayout.Popup(chosenCreateNewCultureValue, notAvailableLanguagesEnglishNames.ToArray());
                if (GUILayout.Button("Create Language"))
                {
                    CreateNewLanguage(notAvailableLanguagesEnglishNames[chosenCreateNewCultureValue]);
                }

                GUILayout.Label("Translate Languages", EditorStyles.boldLabel);
                //Start the scroll view
                scrollPosition = GUILayout.BeginScrollView(scrollPosition);
                bool languageDeleted = false;
                foreach (CultureInfo info in availableLanguages)
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button(info.EnglishName + " - " + info.Name))
                    {
                        //Open language edit window
                        ShowTranslateWindow(info);
                    }
                    if (GUILayout.Button("Delete", GUILayout.Width(60)))
                    {
                        LocFileUtility.DeleteLanguage(info);
                        languageDeleted = true;
                        break;
                    }
                    EditorGUILayout.EndHorizontal();
                }

                if (languageDeleted)                //Refresh
                {
                    LocFileUtility.CheckAvailableLanguages(availableLanguages, notAvailableLanguages, notAvailableLanguagesEnglishNames);
                }

                //End the scroll view
                GUILayout.EndScrollView();
                undoManager.CheckDirty();
            }
        }
    }
Exemplo n.º 20
0
    override public void OnInspectorGUI()
    {
        bool Error = false;

        //int OrigToothCount = _gs.QtyTeeth;
        //float ScaleFact = 1.0f;
        //float ToothHeight = 0.0f;
        undoManager.CheckUndo();
        GUILayout.Label("Modify Gear (Gears By BrainTwinkie)", EditorStyles.boldLabel);

        _gs.QtyTeeth = EditorGUILayout.IntSlider("Qty Teeth", _gs.QtyTeeth, 1, 1000, GUILayout.ExpandWidth(true));
        //_gs.LockRatio = EditorGUILayout.Toggle("Lock Tooth/Radius Ratio", _gs.LockRatio);

        /*
         * if(_gs.LockRatio){
         *      ScaleFact = (float)_gs.QtyTeeth / (float) OrigToothCount;
         *      ToothHeight = _gs.OutsideToothRadius - _gs.InnerToothRadius;
         *
         *
         *      _gs.InnerToothRadius *= ScaleFact;
         *      _gs.OutsideToothRadius = _gs.InnerToothRadius + ToothHeight;
         *      //_gs.InnerToothRadius *= ScaleFact;
         * }
         */
        _gs.OutsideToothRadius = EditorGUILayout.FloatField("Outside Tooth Radius", _gs.OutsideToothRadius);

        _gs.InnerToothRadius = EditorGUILayout.FloatField("Base Tooth Radius", _gs.InnerToothRadius);

        _gs.RingRadius = EditorGUILayout.FloatField("Ring Radius", _gs.RingRadius);

        _gs.Height = EditorGUILayout.FloatField("Height", _gs.Height);

        if (_gs.InnerToothRadius != 0)
        {
            _gs.SpokeType = (GearSupport.SpokeTypes)EditorGUILayout.EnumPopup("Spoke Type", _gs.SpokeType, GUILayout.ExpandWidth(true));

            if (_gs.SpokeType != GearSupport.SpokeTypes.None && _gs.SpokeType != GearSupport.SpokeTypes.Solid)
            {
                _gs.SpokeCount = EditorGUILayout.IntSlider("Spoke Count", _gs.SpokeCount, 1, 10, GUILayout.ExpandWidth(true));
            }

            if (_gs.SpokeType != GearSupport.SpokeTypes.None)
            {
                _gs.SpokeIndent = EditorGUILayout.FloatField("Spoke Indent", _gs.SpokeIndent);
            }

            if (_gs.SpokeType == GearSupport.SpokeTypes.Straight)
            {
                _gs.hubHeight       = EditorGUILayout.FloatField("Hub Height", _gs.hubHeight);
                _gs.HubRadius       = EditorGUILayout.FloatField("Hub Radius", _gs.HubRadius);
                _gs.HubSides        = EditorGUILayout.IntSlider("Hub Sides", _gs.HubSides, 1, 100, GUILayout.ExpandWidth(true));
                _gs.SpokeWidthInner = EditorGUILayout.FloatField("Spoke Width (Inner)", _gs.SpokeWidthInner);
                _gs.SpokeWidthOuter = EditorGUILayout.FloatField("Spoke Width (Outer)", _gs.SpokeWidthOuter);

                if (_gs.hubHeight >= _gs.Height)
                {
                    EditorGUILayout.LabelField("Warning! Hub Height should be less than Gear Height.", GUILayout.ExpandWidth(true));
                }
            }


            EditorGUILayout.LabelField("", GUILayout.ExpandWidth(true));
        }

        _gs.TopScalePct = EditorGUILayout.FloatField("Top Scale %", _gs.TopScalePct);

        _gs.TopRotation = EditorGUILayout.FloatField("Top Rotation (Deg)", _gs.TopRotation);

        _gs.ToothRotation = EditorGUILayout.FloatField("Tooth Rotation (Deg)", _gs.ToothRotation);

        _gs.ToothWidthPct = EditorGUILayout.FloatField("Outside Tooth Width %", _gs.ToothWidthPct);

        _gs.GearMaterial = (Material)EditorGUILayout.ObjectField("Gear Material", (Material)_gs.GearMaterial, typeof(Material), false, GUILayout.Height(16));
        //DebugTextMaterial = (Material)EditorGUILayout.ObjectField("DebugText Material",(Material)DebugTextMaterial, typeof(Material), false, GUILayout.Height(16));
        //DebugTextFont = (Font)EditorGUILayout.ObjectField("DebugText Font",(Font)DebugTextFont, typeof(Font), false, GUILayout.Height(16));
        //DebugTextMaterial = DebugTextFont.material;


        EditorGUILayout.LabelField("", GUILayout.ExpandWidth(true));

        if (_gs.RingRadius > _gs.InnerToothRadius)
        {
            EditorGUILayout.LabelField("ERROR! Ring Radius larger than the Inner tooth radius.", GUILayout.ExpandWidth(true));
            Error = true;
        }

        if (_gs.RingRadius < 0)
        {
            EditorGUILayout.LabelField("ERROR! Ring Radius must be greater than or 0.", GUILayout.ExpandWidth(true));
            Error = true;
        }

        if (_gs.ToothWidthPct < 0)
        {
            EditorGUILayout.LabelField("ERROR! Tooth Width % must be greater than or 0.", GUILayout.ExpandWidth(true));
            Error = true;
        }

        if (_gs.OutsideToothRadius < _gs.InnerToothRadius)
        {
            EditorGUILayout.LabelField("ERROR! Outside Tooth Radius must be greater than the Inner Tooth Radius.", GUILayout.ExpandWidth(true));
            Error = true;
        }

        if (_gs.Height <= 0)
        {
            EditorGUILayout.LabelField("ERROR! Height must be greater than 0.", GUILayout.ExpandWidth(true));
            Error = true;
        }

        if (_gs.SpokeType == GearSupport.SpokeTypes.Straight)
        {
            float inctheta;
            float spokeadj;
            inctheta = 2.0f * (Mathf.PI / _gs.QtyTeeth);
            float r = Mathf.Sqrt((_gs.SpokeWidthInner) * (_gs.SpokeWidthInner) + (_gs.HubRadius * _gs.HubRadius));
            spokeadj = 2.0f * Mathf.Asin(_gs.SpokeWidthInner / (8.0f * r));             //Calc'd using cord of circ.
            if (inctheta - spokeadj <= spokeadj)
            {
                EditorGUILayout.LabelField("Warning! Spoke width and hub radius may create overlapping verts.", GUILayout.ExpandWidth(true));
                //Error = true;
            }
        }



        if (_gs.GearMaterial == null)
        {
            EditorGUILayout.LabelField("Warning! Material Not Assigned.", GUILayout.ExpandWidth(true));
        }

        EditorGUILayout.LabelField("", GUILayout.ExpandWidth(true));
        if (!Error)
        {
            if (GUILayout.Button("Apply"))
            {
                undoManager.CheckDirty();                 // Check dirty  AFTER all GUI code.
                UpdateGear();
            }
        }
        else
        {
            EditorGUILayout.LabelField("Clear errors to create gears.", GUILayout.ExpandWidth(true));
            undoManager.CheckDirty();             // Check dirty  AFTER all GUI code.
        }

        if (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
        {
            UpdateGear();
        }
    }
    void OnGUI()
    {
        if (EditorWindowUtility.ShowWindow())
        {
            undoManager.CheckUndo();
            GUILayout.Label("Root Values", EditorStyles.boldLabel);

            //Search field
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Search for Key:", GUILayout.Width(100));
            searchText = EditorGUILayout.TextField(searchText);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Key Type", GUILayout.Width(100));
            GUILayout.Label("Key");
            GUILayout.Label("Base Value/Comment");
            GUILayout.Label("Delete", EditorStyles.miniLabel, GUILayout.Width(50));
            EditorGUILayout.EndHorizontal();

            //Create the scroll view
            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

            //Delete key information
            bool deleteKey     = false;
            int  indexToDelete = 0;

            //Check if the user searched for a value
            bool didSearch = false;
            if (searchText != "")
            {
                didSearch = true;
                GUILayout.Label("Search Results - \"" + searchText + "\":", EditorStyles.boldLabel);
            }

            for (int i = 0; i < changedRootKeys.Count; i++)
            {
                SerializableStringPair rootValue = changedRootKeys[i];
                if (didSearch)
                {
                    //If the name of the key doesn't contain the search value, then skip a value
                    if (!rootValue.originalValue.ToLower().Contains(searchText.ToLower()))
                    {
                        continue;
                    }
                }
                EditorGUILayout.BeginHorizontal();

                //Popup of all the different key values
                changedRootValues[i].changedValue.ObjectType = (LocalizedObjectType)EditorGUILayout.Popup((int)changedRootValues[i].changedValue.ObjectType,
                                                                                                          keyTypes, GUILayout.Width(100));

                rootValue.changedValue = EditorGUILayout.TextField(rootValue.changedValue);
                changedRootValues[i].changedValue.TextValue = EditorGUILayout.TextField(changedRootValues[i].changedValue.TextValue);
                if (GUILayout.Button("Delete", GUILayout.Width(50)))
                {
                    deleteKey     = true;
                    indexToDelete = i;
                }

                EditorGUILayout.EndHorizontal();
            }

            //End the scrollview
            EditorGUILayout.EndScrollView();

            if (GUILayout.Button("Add New Key"))
            {
                AddNewKey();
            }

            //Delete the key outside the foreach loop
            if (deleteKey)
            {
                DeleteKey(indexToDelete);
            }

            if (guiChanged)
            {
                GUILayout.Label("- You have unsaved changes", EditorStyles.miniLabel);
            }

            //If any changes to the gui is made
            if (GUI.changed)
            {
                guiChanged = true;
            }

            GUILayout.Label("Save Changes", EditorStyles.boldLabel);
            GUILayout.Label("Remember to always press save when you have changed values", EditorStyles.miniLabel);
            if (GUILayout.Button("Save Root Language File"))
            {
                Dictionary <string, string> changeNewRootKeys   = new Dictionary <string, string>();
                Dictionary <string, string> changeNewRootValues = new Dictionary <string, string>();

                for (int i = 0; i < changedRootKeys.Count; i++)
                {
                    SerializableStringPair             rootKey   = changedRootKeys[i];
                    SerializableLocalizationObjectPair rootValue = changedRootValues[i];
                    //Check for possible duplicates and rename them
                    string newKeyValue = LocFileUtility.AddNewKeyPersistent(changeNewRootKeys, rootKey.originalValue, rootValue.changedValue.GetFullKey(rootKey.changedValue));

                    //Check for possible duplicates and rename them(same as above)
                    LocFileUtility.AddNewKeyPersistent(changeNewRootValues, newKeyValue, rootValue.changedValue.TextValue);
                }

                //Add the full values before saving
                Dictionary <string, string> changeNewRootKeysToSave   = new Dictionary <string, string>();
                Dictionary <string, string> changeNewRootValuesToSave = new Dictionary <string, string>();

                foreach (KeyValuePair <string, string> rootKey in changeNewRootKeys)
                {
                    LocalizedObject thisLocalizedObject = parsedRootValues[rootKey.Key];
                    changeNewRootKeysToSave.Add(thisLocalizedObject.GetFullKey(rootKey.Key), rootKey.Value);
                    changeNewRootValuesToSave.Add(thisLocalizedObject.GetFullKey(rootKey.Key), changeNewRootValues[rootKey.Key]);
                }

                LocFileUtility.SaveRootLanguageFile(changeNewRootKeysToSave, changeNewRootValuesToSave);

                //Fire the root language changed event
                if (OnRootFileChanged != null)
                {
                    OnRootFileChanged();
                }

                //Reload the window(in case of duplicate keys)
                SetRootValues(LocFileUtility.LoadParsedLanguageFile(null));
                guiChanged = false;
            }

            undoManager.CheckDirty();
        }
    }
Exemplo n.º 22
0
        void OnGUI()
        {
            undoManager.CheckUndo();

            GUILayout.Label("Export Settings", EditorStyles.boldLabel);
            assetBundleFolderLocation = EditorGUILayout.TextField("AssetBundles folder", assetBundleFolderLocation);
            GUILayout.Label("Application.dataPath			 "+ Application.dataPath, EditorStyles.label);
            exportLocation      = EditorGUILayout.TextField("Export folder", exportLocation);
            bundleFileExtension = EditorGUILayout.TextField("Bundle file ext.", bundleFileExtension);
            setLowerCaseName    = EditorGUILayout.Toggle("Names to lower case", setLowerCaseName);

            buildAssetBundleOptions  = EditorGUILayout.BeginToggleGroup("BuildAssetBundleOptions", buildAssetBundleOptions);
            collectDependencies      = EditorGUILayout.Toggle("CollectDependencies", collectDependencies);
            completeAssets           = EditorGUILayout.Toggle("CompleteAssets", completeAssets);
            disableWriteTypeTree     = EditorGUILayout.Toggle("DisableWriteTypeTree", disableWriteTypeTree);
            deterministicAssetBundle = EditorGUILayout.Toggle("DeterministicAssetBundle", deterministicAssetBundle);
            uncompressedAssetBundle  = EditorGUILayout.Toggle("UncompressedAssetBundle", uncompressedAssetBundle);
            EditorGUILayout.EndToggleGroup();

            optionalSettings = EditorGUILayout.BeginToggleGroup("Optional Settings", optionalSettings);
            buildTarget      = (BuildTarget)EditorGUILayout.EnumPopup("Build Target", buildTarget);
            EditorGUILayout.EndToggleGroup();

            undoManager.CheckDirty();

            GUILayout.Label("Reset Settings", EditorStyles.boldLabel);
            if (GUILayout.Button("Reset"))
            {
                ClearPreferences(this);
                WriteEditorPrefs(this);
                CreateAssetBundles.ReadBundleControlFile(Application.dataPath + exportLocation + CreateAssetBundles.bundleControlFileName, bundleVersions);
                CreateAssetBundles.ReadBundleContentsFile(Application.dataPath + exportLocation + CreateAssetBundles.bundleContentsFileName, bundleContents);
                ReadBundleFileSizes();
            }

            GUILayout.Label("Build", EditorStyles.boldLabel);
            if (GUILayout.Button("Build Asset Bundles"))
            {
                if (!CreateAssetBundles.ExportAssetBundleFolders(this))
                {
                    Debug.LogError("AssetBundle Build Failed! - Please check your settings in the Bundle Creator at Assets->Bundle Creator-> Asset Bundle Creator.");
                }
                else
                {
                    //It worked, save the preferences and reload the control file
                    WriteEditorPrefs(this);
                    bundleVersions.Clear();
                    bundleContents.Clear();
                    bundleFileSizes.Clear();
                    CreateAssetBundles.ReadBundleControlFile(Application.dataPath + exportLocation + CreateAssetBundles.bundleControlFileName, bundleVersions);
                    CreateAssetBundles.ReadBundleContentsFile(Application.dataPath + exportLocation + CreateAssetBundles.bundleContentsFileName, bundleContents);
                    ReadBundleFileSizes();
                }
            }

            GUILayout.Label("Bundle Versions", EditorStyles.boldLabel);
            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
            foreach (KeyValuePair <string, int> bundleVersion in bundleVersions)
            {
                float bundleFileSize = 0;
                bundleFileSizes.TryGetValue(bundleVersion.Key, out bundleFileSize);
                if (GUILayout.Button(bundleVersion.Key + ", Version:" + bundleVersion.Value + ", Size: " + bundleFileSize + "kb"))
                {
                    List <string> assetsInBundle = null;
                    bundleContents.TryGetValue(bundleVersion.Key, out assetsInBundle);
                    if (assetsInBundle != null)
                    {
                        CreateContentWindow();
                        contentWindow.SelectAssetBundle(bundleVersion.Key, assetsInBundle, Application.dataPath + exportLocation, bundleFileSize);
                        contentWindow.ShowTab();
                    }
                }
            }


#if !UNITY_WEBPLAYER
            GUILayout.Label("FTP Upload Settings", EditorStyles.boldLabel);
            string strRemoteHostName = "ftp://bubblemon-l.upload.llnw.net";
            strRemoteHostName = EditorGUILayout.TextField("Remote Host Name", strRemoteHostName);
            string strRemoteUserName = "******";
            strRemoteUserName = EditorGUILayout.TextField("Remote User Name", strRemoteUserName);
            string strPassword = "******";
            strPassword = EditorGUILayout.PasswordField("Password", strPassword);
            string strDesirePath = "/content/bubblemon/qa1/AssetBundles/";
            strDesirePath = EditorGUILayout.TextField("Desire Path", strDesirePath);
            if (GUILayout.Button("Upload AssetBundle"))
            {
                FrameWork.Util.Uploader.FTPClient ftpClient = new FrameWork.Util.Uploader.FTPClient(strRemoteHostName, strRemoteUserName, strPassword, strDesirePath);

                DirectoryInfo info      = new DirectoryInfo(Application.dataPath + exportLocation);
                FileInfo[]    filesInfo = info.GetFiles();

                foreach (FileInfo fileInfo in filesInfo)
                {
                    ftpClient.UploadFile(fileInfo.FullName);
                }
            }
#else
            GUILayout.Label("FTP Upload Settings is available without webplayer platform. please swith build setting.");
#endif

            EditorGUILayout.EndScrollView();
        }