Пример #1
0
    /// <summary>
    /// Draws the window content: object list, configuration and execution buttons.
    /// </summary>
    void OnGUI()
    {
        #region Draw Top Buttons

        GUILayout.BeginHorizontal(EditorStyles.toolbar);
        {
            editMode = GUILayout.Toggle(editMode, new GUIContent("Start replacing", "Start using this feature"), EditorStyles.toggle);
            GUILayout.FlexibleSpace();
        }
        GUILayout.EndHorizontal();
        #endregion

        #region "TAG LAYER"

        SearchWithTag   = GUILayout.Toggle(!SearchWithLayer ? SearchWithTag : false, "Apply Search By Tag", EditorStyles.toggle);
        SearchWithLayer = GUILayout.Toggle(!SearchWithTag ? SearchWithLayer : false, "Apply Search By Layer");

        if (SearchWithTag)
        {
            GUILayout.Space(5);
            TagForSearch = EditorGUILayout.TagField("Set tag :  ", TagForSearch);
        }
        else if (SearchWithLayer)
        {
            GUILayout.Space(5);
            LayerForSearch = EditorGUILayout.LayerField("Set layer :  ", LayerForSearch);
        }
        #endregion "TAG LAYER"

        if (GUI.changed)
        {
            if (editMode)
            {
                GetSelection();
            }
            else
            {
                ResetPreview();
            }
        }

        GUILayout.Space(10);
        if (editMode)
        {
            SetNamingScheme();
            RenamePreview();

            #region Draw Prefab and List

            GUILayout.Label("Prefab: ", EditorStyles.boldLabel);
            prefab = (GameObject)EditorGUILayout.ObjectField(prefab, typeof(GameObject), true);
            if (oldPrefab != prefab)
            {
                GetSelection();
                oldPrefab = prefab;
            }
            GUILayout.Space(10);

            if (prefab != null)
            {
                if (objectsToReplace.Count > 0)
                {
                    GUILayout.Label(new GUIContent("Objects to be Replaced:", (!SearchWithTag && !SearchWithLayer) ? "Multi-select all the objects you want to replace with your Prefab" : ""), EditorStyles.boldLabel);

                    objectPreview.Sort(new NaturalComparer());

                    scrollPosition = GUILayout.BeginScrollView(scrollPosition, EditorStyles.helpBox);
                    {
                        GUILayout.BeginHorizontal(EditorStyles.helpBox);
                        {
                            string previewText = "No Preview";

                            if (replacementPreferences.renameObjects && !replacementPreferences.orderHierarchyToPreview)
                            {
                                previewText = "Preview of Renaming";
                            }
                            else if (replacementPreferences.orderHierarchyToPreview && !replacementPreferences.renameObjects)
                            {
                                previewText = "Preview of Hierarchy Order";
                            }
                            else if (replacementPreferences.orderHierarchyToPreview && replacementPreferences.renameObjects)
                            {
                                previewText = "Preview of Renaming and Hierarchy Order";
                            }

                            GUILayout.Label(previewText, EditorStyles.miniLabel);
                        }
                        GUILayout.EndHorizontal();

                        foreach (string go in objectPreview)
                        {
                            GUILayout.BeginHorizontal(EditorStyles.toolbar);
                            GUILayout.Label(go);
                            GUILayout.EndHorizontal();
                        }
                        GUILayout.Space(2);
                    }
                    GUILayout.EndScrollView();

                    GUILayout.Space(5);

                    replacementPreferences.renameObjects           = GUILayout.Toggle(replacementPreferences.renameObjects, "Rename replaced objects", EditorStyles.toggle);
                    replacementPreferences.orderHierarchyToPreview = GUILayout.Toggle(replacementPreferences.orderHierarchyToPreview, "Oder hierarchy to preview", EditorStyles.toggle);
                    GUILayout.Space(10);
                    replacementPreferences.applyRotation = GUILayout.Toggle(replacementPreferences.applyRotation, "Apply rotation", EditorStyles.toggle);
                    replacementPreferences.applyScale    = GUILayout.Toggle(replacementPreferences.applyScale, "Apply scale", EditorStyles.toggle);
                }
                else if (!SearchWithTag && !SearchWithLayer)
                {
                    GUILayout.Label(new GUIContent("Multi-select all the objects you want to replace with your Prefab"), EditorStyles.boldLabel);
                }
            }
            else
            {
                GUILayout.Label("Select a Prefab to replace objects with", EditorStyles.boldLabel);
            }
            #endregion

            #region Draw Bottom Buttons

            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            {
                if (prefab != null && objectsToReplace.Count > 0)
                {
                    if (GUILayout.Button("Apply"))
                    {
                        foreach (GameObject go in objectsToReplace)
                        {
                            Replace(go);
                            DestroyImmediate(go);
                        }
                        if (replacementPreferences.renameObjects)
                        {
                            Rename();
                        }
                        editMode = false;
                        EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());     // Important so that we don't forget to save!
                    }
                    else if (GUILayout.Button("Cancel"))
                    {
                        objectsToReplace.Clear();
                        objectPreview.Clear();
                        ResetPreview();
                        prefab = null;
                    }
                }
            }
            GUILayout.EndHorizontal();
            #endregion
        }
        else
        {
            objectsToReplace.Clear();
            objectPreview.Clear();
            newObjects.Clear();
            prefab = null;
        }
    }
Пример #2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            EditorGUILayout.Space();

            #region Properties
            showProperties.boolValue = EditorTools.BeginFoldOut("Properties", showProperties.boolValue);
            if (showProperties.boolValue || showProperties.hasMultipleDifferentValues)
            {
                EditorTools.BeginGroup(); {
                    EditorGUILayout.PropertyField(autonomous);
                    EditorGUILayout.PropertyField(autoTarget);
                    EditorGUILayout.PropertyField(autoReTarget, new GUIContent("Auto re-target"));
                    if (autoTarget.boolValue || autoTarget.hasMultipleDifferentValues || autoReTarget.boolValue || autoReTarget.hasMultipleDifferentValues)
                    {
                        EditorGUILayout.PropertyField(maxMissileOnTarget, new GUIContent("Max on target"));
                    }
                    if (autoTarget.boolValue)
                    {
                        EditorGUILayout.HelpBox("Radar component required", MessageType.Info);
                    }
                    //Life time
                    EditorGUILayout.PropertyField(lifeTime);

                    // Layer mash
                    EditorGUILayout.PropertyField(layerMask);

                    //subweapon
                    EditorGUILayout.PropertyField(subWeapon);
                } EditorTools.EndGroup();
            }
            #endregion

            #region Damage
            showDamage.boolValue = EditorTools.BeginFoldOut("Damage", showDamage.boolValue);
            if (showDamage.boolValue || showDamage.hasMultipleDifferentValues)
            {
                EditorTools.BeginGroup(); {
                    // Damge
                    EditorGUILayout.PropertyField(projectileDamage, new GUIContent("At"));

                    // Type
                    EditorGUILayout.PropertyField(damageType, new GUIContent("Type"));
                    if (damageType.enumValueIndex == 1)
                    {
                        EditorGUILayout.PropertyField(damageRadius, new GUIContent("Explosion radius"));
                    }

                    // Nature
                    if (!damageNature.hasMultipleDifferentValues)
                    {
                        damageNature.intValue = EditorGUILayout.Popup("Nature", damageNature.intValue, damageLabels);
                    }
                    else
                    {
                        int tmpDamageNature = EditorGUILayout.Popup("Nature", -1, damageLabels);
                        if (tmpDamageNature != damageNature.intValue && tmpDamageNature > -1)
                        {
                            damageNature.intValue = tmpDamageNature;
                        }
                    }
                    EditorGUILayout.Space();

                    EditorGUILayout.PropertyField(randomDamagePoint, new GUIContent("Random damage"));
                    if (!randomDamagePoint.hasMultipleDifferentValues)
                    {
                        if (!randomDamagePoint.boolValue)
                        {
                            EditorGUILayout.PropertyField(damagePoint, new GUIContent("Point"));
                        }
                        else
                        {
                            EditorGUILayout.PropertyField(damagePoint, new GUIContent("Min Point"));
                            EditorGUILayout.PropertyField(damagePointMax, new GUIContent("Max Point"));
                        }
                    }
                    else
                    {
                        EditorGUILayout.PropertyField(damagePoint, new GUIContent("Point"));
                        EditorGUILayout.PropertyField(damagePointMax, new GUIContent("Max Point"));
                    }
                    EditorGUILayout.Space();

                    EditorGUILayout.PropertyField(isPhysic, new GUIContent("Add force at impact"));
                    if (isPhysic.boolValue || isPhysic.hasMultipleDifferentValues)
                    {
                        EditorGUILayout.PropertyField(force);
                        EditorGUILayout.PropertyField(forceMode);
                    }
                } EditorTools.EndGroup();
            }
            #endregion

            #region Projectile physic
            showPhysic.boolValue = EditorTools.BeginFoldOut("Physic", showPhysic.boolValue);
            if (showPhysic.boolValue || showPhysic.hasMultipleDifferentValues)
            {
                EditorTools.BeginGroup(); {
                    EditorGUILayout.PropertyField(useAdvance);
                    EditorGUILayout.PropertyField(velocity, new GUIContent("Velocity"));
                    EditorGUILayout.PropertyField(straightTime, new GUIContent("Straight time (s)"));
                    EditorGUILayout.PropertyField(angularSpeed);
                    EditorGUILayout.PropertyField(chaos);
                    EditorGUILayout.PropertyField(chaosFrenquency);

                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(rayAdvance, new GUIContent("Ray Advance"));
                    EditorGUILayout.PropertyField(rayRadius, new GUIContent("Ray radius"));
                } EditorTools.EndGroup();
            }
            #endregion

            #region Effect
            showEffect.boolValue = EditorTools.BeginFoldOut("Effects", showEffect.boolValue);
            if (showEffect.boolValue || showEffect.hasMultipleDifferentValues)
            {
                EditorTools.BeginGroup(); {
                    EditorGUILayout.PropertyField(impactEffect);
                    EditorGUILayout.PropertyField(deathEffect);
                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(timedEffect);
                    EditorGUILayout.PropertyField(time);
                } EditorTools.EndGroup();
            }
            #endregion

            serializedObject.ApplyModifiedProperties();

            if (GUI.changed && !EditorApplication.isPlaying)
            {
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }
Пример #3
0
        public override void OnInspectorGUI()
        {
            if (_isoObj.transform.parent != null && _isoObj.world == null)
            {
                _isoObj.world = _isoObj.transform.GetComponentInParent <IsoWorld>();
            }

            serializedObject.Update();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("showGrid"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("gizmosColor"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_nodeX"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_nodeZ"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("spanX"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("spanZ"), true);
            serializedObject.ApplyModifiedProperties();

            if (!Application.isPlaying)
            {
                if (_isoObj.nodeX != _nodeX || _isoObj.nodeZ != _nodeZ)
                {
                    _nodeX = _isoObj.nodeX;
                    _nodeZ = _isoObj.nodeZ;
                    _isoObj.SetNodePosition(_nodeX, _nodeZ);
                }

                if (_isoObj.spanX != _spanX || _isoObj.spanZ != _spanZ)
                {
                    _spanX = _isoObj.spanX;
                    _spanZ = _isoObj.spanZ;
                    HandleUtility.Repaint();
                }
            }


            EditorGUILayout.Space();
            serializedObject.Update();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_isRotated"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("world"), true);
            serializedObject.ApplyModifiedProperties();

            if (serializedObject.FindProperty("m_isRotated").boolValue != _rotateX)
            {
                _rotateX = serializedObject.FindProperty("m_isRotated").boolValue;
                _isoObj.RotateX(_rotateX);
            }

            if (!_isPrefab())
            {
                EditorGUILayout.Space();
                if (GUILayout.Button("Align To Grid", GUILayout.Height(20)))
                {
                    if (_isoObj.world)
                    {
                        Vector2 nodePos = _isoObj.world.LocalPosToGridPos(_isoObj.transform.localPosition.x, _isoObj.transform.localPosition.y);
                        _nodeX = (int)nodePos.x;
                        _nodeZ = (int)nodePos.y;
                        _isoObj.SetNodePosition(_nodeX, _nodeZ);
                        if (!Application.isPlaying && !_isPrefab())
                        {
                            serializedObject.ApplyModifiedProperties();
                            EditorUtility.SetDirty(_isoObj);
                            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                        }
                    }
                }
            }
        }
Пример #4
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        Undo.RecordObject(mySelectedScript, "Edited Something");
        EditorGUI.BeginChangeCheck();

        if (GUILayout.Button("GeneratePools", GUILayout.MinHeight(50)))
        {
            ClearPools(mySelectedScript.prefabsInstations);
            BeginPooling();
            EditorSceneManager.MarkSceneDirty(mySelectedScript.gameObject.scene);
        }

        EditorGUI.EndChangeCheck();

        void BeginPooling()
        {
            for (int i = 0; i < mySelectedScript.prefabsInstations.Length; i++)
            {
                EnHancePooling(mySelectedScript.prefabsInstations[i]);
            }
        }

        void EnHancePooling(PrefabsPoolingParameters basicCharacts)
        {
            for (int j = 0; j < basicCharacts.numberToGenerate; j++)
            {
                Mb_Poolable newItem = Instantiate(basicCharacts.pooledItem);
                newItem.transform.parent = basicCharacts.associatedTransformPos.transform;
                newItem.gameObject.SetActive(false);
                basicCharacts.associatedTransformPos.listOfPoolableItem
                .Add(newItem);

                PrefabUtility.RecordPrefabInstancePropertyModifications(mySelectedScript);
            }

            for (int p = 0; p < mySelectedScript.prefabsInstations.Length; p++)
            {
                PrefabUtility.RecordPrefabInstancePropertyModifications(mySelectedScript.prefabsInstations[p].associatedTransformPos);
            }
            EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
        }

        void ClearPools(PrefabsPoolingParameters[] basicCharacts)
        {
            for (int j = 0; j < basicCharacts.Length; j++)
            {
                basicCharacts[j].associatedTransformPos.listOfPoolableItem.Clear();

                Transform parent      = basicCharacts[j].associatedTransformPos.transform;
                int       safeCounter = 0;

                while (parent.childCount > 0)
                {
                    DestroyImmediate(parent.GetChild(0).gameObject);
                    safeCounter++;
                    if (safeCounter > 10000)
                    {
                        break;
                    }
                }
            }
        }
    }
Пример #5
0
    private static void LoadItems(bool testingInEditor)
    {
        int buildIndex = EditorSceneManager.GetActiveScene().buildIndex;

        bool canCreateAssetDatabase = (testingInEditor) ? true : (buildIndex == 0);

        // We only want to create this object at the first scene.
        if (canCreateAssetDatabase)
        {
            guidCache = new HashSet <string>();

            if (BuildPipeline.isBuildingPlayer)
            {
                var scene = EditorSceneManager.GetActiveScene();
                EditorSceneManager.MarkSceneDirty(scene);
            }

            GameObject assetDataBase = new GameObject("Scriptable Asset Database");

            EditorUtility.SetDirty(assetDataBase);

            ScriptableAssetDatabase dataBase = assetDataBase.AddComponent <ScriptableAssetDatabase>();

            EditorUtility.SetDirty(dataBase);

            string[] lookPath      = new string[] { "Assets/ScriptableObjects", "Upload/Assets/ScriptableObjects" };
            string[] itemGuidPaths = AssetDatabase.FindAssets("t:ScriptableObject", lookPath);

            for (int i = 0; i < itemGuidPaths.Length; i++)
            {
                string path = AssetDatabase.GUIDToAssetPath(itemGuidPaths[i]);
                IReferenceableAsset getItemData = AssetDatabase.LoadAssetAtPath <ScriptableObject>(path) as IReferenceableAsset;

                if (getItemData != null)
                {
                    string           guid  = getItemData.GetGuid().ToString();
                    ScriptableObject asset = getItemData as ScriptableObject;

                    bool isGuidDuplicate = guidCache.Contains(guid);

                    // Check if guid is valid or duplicate, if so then we assign a new one for the asset.
                    // And we ensure this gets saved within the editor.
                    if (string.IsNullOrEmpty(getItemData.GetGuid()) || isGuidDuplicate)
                    {
                        getItemData.GenerateNewGuid();
                        guid = getItemData.GetGuid().ToString();

                        EditorUtility.SetDirty((ScriptableObject)getItemData);

                        Debug.Log($"Found duplicate guid on {getItemData}");
                    }

                    dataBase.values.Add(asset);
                    dataBase.keys.Add(guid);

                    // Fast way to do a lookup in case there is a duplicate guid
                    guidCache.Add(guid);
                }
            }
        }
    }
Пример #6
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            UIPainter panel = target as UIPainter;

#if (UNITY_5 || UNITY_5_3_OR_NEWER)
            DrawPropertiesExcluding(serializedObject, propertyToExclude);
#endif
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Package Name");
            if (GUILayout.Button(packageName.stringValue, "ObjectField"))
            {
                EditorWindow.GetWindow <PackagesWindow>(true, "Select a UI Component").SetSelection(packageName.stringValue, componentName.stringValue);
            }

            if (GUILayout.Button("Clear", GUILayout.Width(50)))
            {
#if UNITY_2018_3_OR_NEWER
                bool isPrefab = PrefabUtility.GetPrefabAssetType(panel) != PrefabAssetType.NotAPrefab;
#else
                bool isPrefab = PrefabUtility.GetPrefabType(panel) == PrefabType.Prefab;
#endif
                panel.SendMessage("OnUpdateSource", new object[] { null, null, null, !isPrefab });

#if UNITY_5_3_OR_NEWER
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
#elif UNITY_5
                EditorApplication.MarkSceneDirty();
#else
                EditorUtility.SetDirty(panel);
#endif
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Component Name");
            if (GUILayout.Button(componentName.stringValue, "ObjectField"))
            {
                EditorWindow.GetWindow <PackagesWindow>(true, "Select a UI Component").SetSelection(packageName.stringValue, componentName.stringValue);
            }
            EditorGUILayout.EndHorizontal();
            int oldSortingOrder = panel.sortingOrder;
            EditorGUILayout.PropertyField(sortingOrder);
            EditorGUILayout.PropertyField(renderCamera);
            EditorGUILayout.PropertyField(fairyBatching);
            EditorGUILayout.PropertyField(touchDisabled);

            if (serializedObject.ApplyModifiedProperties())
            {
#if UNITY_2018_3_OR_NEWER
                bool isPrefab = PrefabUtility.GetPrefabAssetType(panel) != PrefabAssetType.NotAPrefab;
#else
                bool isPrefab = PrefabUtility.GetPrefabType(panel) == PrefabType.Prefab;
#endif
                if (!isPrefab)
                {
                    panel.ApplyModifiedProperties(sortingOrder.intValue != oldSortingOrder);
                }
            }
        }
Пример #7
0
        public static void Button(UnityEngine.Object[] targets, MethodInfo methodInfo)
        {
            bool visible = ButtonUtility.IsVisible(targets, methodInfo);

            if (!visible)
            {
                return;
            }

            if (methodInfo.GetParameters().All(p => p.IsOptional))
            {
                ButtonAttribute buttonAttribute = (ButtonAttribute)methodInfo.GetCustomAttributes(typeof(ButtonAttribute), true)[0];
                string          buttonText      = string.IsNullOrEmpty(buttonAttribute.Text) ? ObjectNames.NicifyVariableName(methodInfo.Name) : buttonAttribute.Text;

                bool buttonEnabled = ButtonUtility.IsEnabled(targets, methodInfo);

                EButtonEnableMode mode = buttonAttribute.SelectedEnableMode;
                buttonEnabled &=
                    mode == EButtonEnableMode.Always ||
                    mode == EButtonEnableMode.Editor && !Application.isPlaying ||
                    mode == EButtonEnableMode.Playmode && Application.isPlaying;

                bool methodIsCoroutine = methodInfo.ReturnType == typeof(IEnumerator);
                if (methodIsCoroutine)
                {
                    buttonEnabled &= (Application.isPlaying ? true : false);
                }

                EditorGUI.BeginDisabledGroup(!buttonEnabled);

                if (GUILayout.Button(buttonText, _buttonStyle))
                {
                    object[] defaultParams = methodInfo.GetParameters().Select(p => p.DefaultValue).ToArray();
                    foreach (var target in targets)
                    {
                        IEnumerator methodResult = methodInfo.Invoke(target, defaultParams) as IEnumerator;

                        if (!Application.isPlaying)
                        {
                            // Set target object and scene dirty to serialize changes to disk
                            EditorUtility.SetDirty(target);

                            PrefabStage stage = PrefabStageUtility.GetCurrentPrefabStage();
                            if (stage != null)
                            {
                                // Prefab mode
                                EditorSceneManager.MarkSceneDirty(stage.scene);
                            }
                            else
                            {
                                // Normal scene
                                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                            }
                        }
                        else if (methodResult != null && target is MonoBehaviour behaviour)
                        {
                            behaviour.StartCoroutine(methodResult);
                        }
                    }
                }

                EditorGUI.EndDisabledGroup();
            }
            else
            {
                string warning = typeof(ButtonAttribute).Name + " works only on methods with no parameters";
                HelpBox_Layout(warning, MessageType.Warning, context: targets[0], logToConsole: true);
            }
        }
        public override void OnInspectorGUI()
        {
            if (Application.isPlaying)
            {
                return;
            }

            Debug.Log("ON INSPECTOR GUI");

            Undo.RecordObject(target, "EventTriggerBehaviour");

            EventTriggerBehaviour behaviour = target as EventTriggerBehaviour;

            DrawDefaultInspector();

            EditorGUILayout.Space();

            //Setup Target GameObject
            if (behaviour.targetObject == null)
            {
                behaviour.targetObject = behaviour.gameObject;
            }

            behaviour.eventTypeIndex = EditorGUILayout.Popup("Event Type", behaviour.eventTypeIndex, new [] { "From Target Object", "From EventTriggerType" });


            bool eventsFound = true;

            if (behaviour.eventTypeIndex == 0)
            {
                behaviour.ClearEventTrigger();

                List <string>    componentNames = new List <string>();
                List <Component> componentsList = new List <Component>();

                List <string> propertiesNames = new List <string>();

                foreach (Component loopComponent in behaviour.targetObject.GetComponents(typeof(Component)))
                {
                    componentsList.Add(loopComponent);
                    componentNames.Add(loopComponent.GetType().ToString());
                }

                behaviour.eventComponentIndex = EditorGUILayout.Popup("Component", behaviour.eventComponentIndex, componentNames.ToArray());

                if (behaviour.eventComponentIndex != -1 && behaviour.eventComponentIndex < componentsList.Count)
                {
                    behaviour.eventComponent = componentsList.ElementAt(behaviour.eventComponentIndex);

                    foreach (PropertyInfo propertyInfo in behaviour.eventComponent.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
                    {
                        if (propertyInfo.PropertyType.BaseType == typeof(UnityEvent))
                        {
                            propertiesNames.Add(propertyInfo.Name);
                        }
                    }


                    if (propertiesNames.Count == 0)
                    {
                        eventsFound = false;
                        EditorGUILayout.LabelField("No Events found");
                    }
                    else
                    {
                        behaviour.eventPropertyIndex = EditorGUILayout.Popup("Property", behaviour.eventPropertyIndex, propertiesNames.ToArray());

                        if (behaviour.eventPropertyIndex != -1 && propertiesNames.Count > behaviour.eventPropertyIndex)
                        {
                            behaviour.eventProperty = propertiesNames.ElementAt(behaviour.eventPropertyIndex);

                            behaviour.selectedUnityEventBase = behaviour.eventComponent.GetType().GetProperty(behaviour.eventProperty).GetValue(behaviour.eventComponent, null) as UnityEventBase;

                            behaviour.RefreshUnityEventBase();
                        }
                    }
                }

                EditorGUILayout.Space();
            }
            else if (behaviour.eventTypeIndex == 1)
            {
                behaviour.eventTriggerType = (EventTriggerType)behaviour.eventIndex;

                if (!Application.isPlaying)
                {
                    behaviour.RefreshEventTriggerList();
                }

                EditorGUILayout.Space();
                behaviour.eventIndex = EditorGUILayout.Popup("Event", behaviour.eventIndex, Enum.GetNames(typeof(EventTriggerType)));
            }


            if (!eventsFound)
            {
                if (!Application.isPlaying)
                {
                    EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                }
                return;
            }

            // Get actions list
            FieldInfo[] fieldsCollection = typeof(TriggersCollection).GetFields(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
            foreach (FieldInfo fieldInfo in fieldsCollection)
            {
                actionsList.Add(fieldInfo.GetValue(null) as Delegate);
                actionsNamesList.Add(fieldInfo.Name);
            }

            behaviour.actionIndex    = EditorGUILayout.Popup("Action", behaviour.actionIndex, actionsNamesList.ToArray());
            behaviour.targetDelegate = actionsList[behaviour.actionIndex];

            CreateArgumentsLists(behaviour);

            if (behaviour.targetDelegate != null)
            {
                if (behaviour.targetDelegate.Method.GetParameters().Length > 0)
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField("Arguments");
                    EditorGUILayout.Space();
                }


                for (int index = 0; index < behaviour.targetDelegate.Method.GetParameters().Length; index++)
                {
                    ParameterInfo parameterInfo = behaviour.targetDelegate.Method.GetParameters()[index];
//                Debug.Log ("Parameter for Delegate: " + parameterInfo.ParameterType + "|" + parameterInfo.Name);

                    string textFieldName = parameterInfo.Name;
                    if (textFieldName == "")
                    {
                        textFieldName = "Argument " + (index + 1);
                    }

                    EditorGUILayout.LabelField(textFieldName + ": " + parameterInfo.ParameterType);

                    behaviour.argsChoiceIndexList[index] = EditorGUILayout.Popup("Argument type", behaviour.argsChoiceIndexList[index], Enum.GetNames(typeof(EventTriggerArgumentKind)));

                    /**STRING TYPE ARGUMENTS*/

                    //STRING
                    if (parameterInfo.ParameterType == typeof(string))
                    {
                        if (behaviour.argsChoiceIndexList[index] == 0)
                        {
                            behaviour.stringArgs[index] = EditorGUILayout.TextField("Value", behaviour.stringArgs[index]);
                        }
                        else
                        {
                            SetupDynamicArgument(behaviour, index, typeof(string));
                        }

                        behaviour.argumentTypes[index] = EventTriggerArgumentType.String;
                    }

                    /**NUMBER TYPE ARGUMENTS*/

                    //INT
                    else if (parameterInfo.ParameterType == typeof(int))
                    {
                        if (behaviour.argsChoiceIndexList[index] == 0)
                        {
                            behaviour.intArgs[index] = EditorGUILayout.IntField("Value", behaviour.intArgs[index]);
                        }
                        else
                        {
                            SetupDynamicArgument(behaviour, index, typeof(int));
                        }

                        behaviour.argumentTypes[index] = EventTriggerArgumentType.Int;
                    }
                    //FLOAT
                    else if (parameterInfo.ParameterType == typeof(float))
                    {
                        if (behaviour.argsChoiceIndexList[index] == 0)
                        {
                            behaviour.floatArgs[index] = EditorGUILayout.FloatField("Value", behaviour.floatArgs[index]);
                        }
                        else
                        {
                            SetupDynamicArgument(behaviour, index, typeof(float));
                        }

                        behaviour.argumentTypes[index] = EventTriggerArgumentType.Float;
                    }
                    //DOUBLE
                    else if (parameterInfo.ParameterType == typeof(double))
                    {
                        if (behaviour.argsChoiceIndexList[index] == 0)
                        {
                            behaviour.doubleArgs[index] = EditorGUILayout.DoubleField("Value", behaviour.doubleArgs[index]);
                        }
                        else
                        {
                            SetupDynamicArgument(behaviour, index, typeof(double));
                        }

                        behaviour.argumentTypes[index] = EventTriggerArgumentType.Double;
                    }

                    /**VECTOR TYPE ARGUMENTS*/

                    //VECTOR 2
                    else if (parameterInfo.ParameterType == typeof(Vector2))
                    {
                        if (behaviour.argsChoiceIndexList[index] == 0)
                        {
                            behaviour.vector2Args[index] = EditorGUILayout.Vector2Field("Value", behaviour.vector2Args[index]);
                        }
                        else
                        {
                            SetupDynamicArgument(behaviour, index, typeof(Vector2));
                        }

                        behaviour.argumentTypes[index] = EventTriggerArgumentType.Vector2;
                    }
                    //VECTOR 3
                    else if (parameterInfo.ParameterType == typeof(Vector3))
                    {
                        if (behaviour.argsChoiceIndexList[index] == 0)
                        {
                            behaviour.vector3Args[index] = EditorGUILayout.Vector3Field("Value", behaviour.vector3Args[index]);
                        }
                        else
                        {
                            SetupDynamicArgument(behaviour, index, typeof(Vector3));
                        }

                        behaviour.argumentTypes[index] = EventTriggerArgumentType.Vector3;
                    }
                    //VECTOR 4
                    else if (parameterInfo.ParameterType == typeof(Vector4))
                    {
                        if (behaviour.argsChoiceIndexList[index] == 0)
                        {
                            behaviour.vector4Args[index] = EditorGUILayout.Vector4Field("Value", behaviour.vector4Args[index]);
                        }
                        else
                        {
                            SetupDynamicArgument(behaviour, index, typeof(Vector4));
                        }

                        behaviour.argumentTypes[index] = EventTriggerArgumentType.Vector4;
                    }

                    /**GAME OBJECT TYPE ARGUMENTS*/

                    //GAME OBJECT
                    else if (parameterInfo.ParameterType == typeof(GameObject))
                    {
                        if (behaviour.argsChoiceIndexList[index] == 0)
                        {
                            behaviour.gameObjectArgs[index] = EditorGUILayout.ObjectField("Value", behaviour.gameObjectArgs[index], typeof(GameObject), true) as GameObject;
                        }
                        else
                        {
                            SetupDynamicArgument(behaviour, index, typeof(GameObject));
                        }

                        behaviour.argumentTypes[index] = EventTriggerArgumentType.GameObject;
                    }

                    //COMPONENT
                    else if (parameterInfo.ParameterType == typeof(Component))
                    {
                        if (behaviour.argsChoiceIndexList[index] == 0)
                        {
                            behaviour.componentArgs[index] = EditorGUILayout.ObjectField("Value", behaviour.componentArgs[index], typeof(Component), true) as Component;
                        }
                        else
                        {
                            SetupDynamicArgument(behaviour, index, typeof(Component));
                        }

                        behaviour.argumentTypes[index] = EventTriggerArgumentType.Component;
                    }

                    /**OTHER TYPE ARGUMENTS*/

                    //COLOR
                    else if (parameterInfo.ParameterType == typeof(Color))
                    {
                        if (behaviour.argsChoiceIndexList[index] == 0)
                        {
                            behaviour.colorArgs[index] = EditorGUILayout.ColorField("Value", behaviour.colorArgs[index]);
                        }
                        else
                        {
                            SetupDynamicArgument(behaviour, index, typeof(Color));
                        }

                        behaviour.argumentTypes[index] = EventTriggerArgumentType.Color;
                    }


                    EditorGUILayout.Space();
                }
            }

            if (!Application.isPlaying)
            {
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
            }
        }
Пример #9
0
        void OnGUI()
        {
            if (itemStyle == null)
            {
                itemStyle = new GUIStyle(GUI.skin.GetStyle("IN Toggle"));
                itemStyle.normal.background    = null;
                itemStyle.onNormal.background  = GUI.skin.GetStyle("ObjectPickerResultsEven").active.background;
                itemStyle.focused.background   = null;
                itemStyle.onFocused.background = null;
                itemStyle.hover.background     = null;
                itemStyle.onHover.background   = null;
                itemStyle.active.background    = null;
                itemStyle.onActive.background  = null;
                itemStyle.margin.top           = 0;
                itemStyle.margin.bottom        = 0;
            }

            EditorGUILayout.BeginHorizontal();

            //package list start------
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(5);

            EditorGUILayout.BeginVertical();
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Packages", (GUIStyle)"OL Title", GUILayout.Width(300));

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(4);

            scrollPos1 = EditorGUILayout.BeginScrollView(scrollPos1, (GUIStyle)"CN Box", GUILayout.Height(300), GUILayout.Width(300));
            EditorToolSet.LoadPackages();
            List <UIPackage> pkgs = UIPackage.GetPackages();
            int cnt = pkgs.Count;

            if (cnt == 0)
            {
                selectedPackage     = -1;
                selectedPackageName = null;
            }
            else
            {
                for (int i = 0; i < cnt; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Space(4);
                    if (GUILayout.Toggle(selectedPackageName == pkgs[i].name, pkgs[i].name, itemStyle, GUILayout.ExpandWidth(true)))
                    {
                        selectedPackage     = i;
                        selectedPackageName = pkgs[i].name;
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndScrollView();

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();

            //package list end------

            //component list start------

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(5);

            EditorGUILayout.BeginVertical();
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Components", (GUIStyle)"OL Title", GUILayout.Width(220));

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(4);

            scrollPos2 = EditorGUILayout.BeginScrollView(scrollPos2, (GUIStyle)"CN Box", GUILayout.Height(300), GUILayout.Width(220));
            if (selectedPackage >= 0)
            {
                List <PackageItem> items = pkgs[selectedPackage].GetItems();
                int i = 0;
                foreach (PackageItem pi in items)
                {
                    if (pi.type == PackageItemType.Component && pi.exported)
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Space(4);
                        if (GUILayout.Toggle(selectedComponentName == pi.name, pi.name, itemStyle, GUILayout.ExpandWidth(true)))
                        {
                            selectedComponentName = pi.name;
                        }
                        i++;
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            EditorGUILayout.EndScrollView();

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();

            //component list end------

            GUILayout.Space(10);

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(20);

            //buttons start---
            EditorGUILayout.BeginHorizontal();

            GUILayout.Space(180);

            if (GUILayout.Button("Refresh", GUILayout.Width(100)))
            {
                EditorToolSet.ReloadPackages();
            }

            GUILayout.Space(20);
            if (GUILayout.Button("OK", GUILayout.Width(100)) && selectedPackage >= 0)
            {
                UIPackage selectedPkg = pkgs[selectedPackage];
                string    tmp         = selectedPkg.assetPath.ToLower();
                string    packagePath;
                int       pos = tmp.LastIndexOf("resources/");
                if (pos != -1)
                {
                    packagePath = selectedPkg.assetPath.Substring(pos + 10);
                }
                else
                {
                    packagePath = tmp;
                }
                bool isPrefab = PrefabUtility.GetPrefabType(Selection.activeGameObject) == PrefabType.Prefab;

                Selection.activeGameObject.SendMessage("OnUpdateSource",
                                                       new object[] { selectedPkg.name, packagePath, selectedComponentName, !isPrefab },
                                                       SendMessageOptions.DontRequireReceiver);
#if UNITY_5_3_OR_NEWER
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
#elif UNITY_5
                EditorApplication.MarkSceneDirty();
#else
                EditorUtility.SetDirty(Selection.activeGameObject);
#endif
                this.Close();
            }

            EditorGUILayout.EndHorizontal();
        }
Пример #10
0
    private void Outline(MaterialEditor materialEditor, MaterialProperty[] properties, GUIStyle style, bool toggle)
    {
        bool ini = toggle;

        toggle = EditorGUILayout.BeginToggleGroup("3.Outline", toggle);
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword("OUTBASE_ON");
            EditorGUILayout.BeginVertical(style);
            {
                materialEditor.ShaderProperty(properties[14], properties[14].displayName);
                materialEditor.ShaderProperty(properties[15], properties[15].displayName);
                materialEditor.ShaderProperty(properties[16], properties[16].displayName);
                materialEditor.ShaderProperty(properties[17], properties[17].displayName);
                MaterialProperty outline8dir = ShaderGUI.FindProperty("_Outline8Directions", properties);
                if (outline8dir.floatValue == 1)
                {
                    targetMat.EnableKeyword("OUTBASE8DIR_ON");
                }
                else
                {
                    targetMat.DisableKeyword("OUTBASE8DIR_ON");
                }

                materialEditor.ShaderProperty(properties[19], properties[19].displayName);
                MaterialProperty outlinePixel = ShaderGUI.FindProperty("_OutlineIsPixel", properties);
                if (outlinePixel.floatValue == 1)
                {
                    targetMat.EnableKeyword("OUTBASEPIXELPERF_ON");
                    materialEditor.ShaderProperty(properties[20], properties[20].displayName);
                }
                else
                {
                    targetMat.DisableKeyword("OUTBASEPIXELPERF_ON");
                    materialEditor.ShaderProperty(properties[18], properties[18].displayName);
                }

                materialEditor.ShaderProperty(properties[21], properties[21].displayName);
                MaterialProperty outlineTex = ShaderGUI.FindProperty("_OutlineTexToggle", properties);
                if (outlineTex.floatValue == 1)
                {
                    targetMat.EnableKeyword("OUTTEX_ON");
                    materialEditor.ShaderProperty(properties[22], properties[22].displayName);
                    materialEditor.ShaderProperty(properties[23], properties[23].displayName);
                    materialEditor.ShaderProperty(properties[24], properties[24].displayName);
                    materialEditor.ShaderProperty(properties[25], properties[25].displayName);
                    MaterialProperty outlineTexGrey = ShaderGUI.FindProperty("_OutlineTexGrey", properties);
                    if (outlineTexGrey.floatValue == 1)
                    {
                        targetMat.EnableKeyword("OUTGREYTEXTURE_ON");
                    }
                    else
                    {
                        targetMat.DisableKeyword("OUTGREYTEXTURE_ON");
                    }
                }
                else
                {
                    targetMat.DisableKeyword("OUTTEX_ON");
                }

                materialEditor.ShaderProperty(properties[26], properties[26].displayName);
                MaterialProperty outlineDistort = ShaderGUI.FindProperty("_OutlineDistortToggle", properties);
                if (outlineDistort.floatValue == 1)
                {
                    targetMat.EnableKeyword("OUTDIST_ON");
                    materialEditor.ShaderProperty(properties[27], properties[27].displayName);
                    materialEditor.ShaderProperty(properties[28], properties[28].displayName);
                    materialEditor.ShaderProperty(properties[29], properties[29].displayName);
                    materialEditor.ShaderProperty(properties[30], properties[30].displayName);
                }
                else
                {
                    targetMat.DisableKeyword("OUTDIST_ON");
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword("OUTBASE_ON");
        }
        EditorGUILayout.EndToggleGroup();
    }
    public void LoadCalibrations()
    {
        string path     = getConfigFolder();
        string fullPath = Path.Combine(path, "WARP - " + Util.ObjectFullName(this.gameObject) + ".conf");

        // LOADS THE WARP VERTICES CALIBRATIONS
        if (File.Exists(fullPath))
        {
            Debug.Log("Loading warp calibration \"" + fullPath + "\"");
            string         content = File.ReadAllText(fullPath);
            string[]       lines   = content.Split('\n');
            List <Vector3> vecs    = new List <Vector3>();
            foreach (string str in lines)
            {
                string[] parts = str.Split('|');
                if (parts.Length > 1)
                {
                    vecs.Add(new Vector3(float.Parse(parts[0].Replace(',', '.')), float.Parse(parts[1].Replace(',', '.')), float.Parse(parts[2].Replace(',', '.'))));
                    Debug.Log(new Vector2(float.Parse(parts[0]), float.Parse(parts[1])));
                }
            }
            this.dewarpMeshPositions.verts = new Vector3[vecs.Count];
            for (int i = 0; i < vecs.Count; i++)
            {
                this.dewarpMeshPositions.verts[i] = vecs[i];
            }
        }
        else
        {
            Debug.LogWarning("Warp calibration file could not be found");
        }

        // LOADS THE DISPLAYS POSITION CALIBRATIONS
        //fullPath = Path.Combine(path, "POS - " + Util.ObjectFullName(this.gameObject) + ".conf");
        //Debug.Log("Loading position calibration \"" + fullPath + "\"");
        //if (File.Exists(fullPath))
        //{
        //    string content = File.ReadAllText(fullPath);
        //    string[] parts = content.Split('|');
        //    Debug.Log(parts);
        //    if (parts.Length > 1)
        //    {
        //        this.transform.localPosition = new Vector3(float.Parse(parts[0].Replace(',', '.')), float.Parse(parts[1].Replace(',', '.')), float.Parse(parts[2].Replace(',', '.')));
        //    }

        //}
        //else
        //{
        //    Debug.LogWarning("Position calibration file could not be found");
        //}

        // LOADS THE DISPLAYS ROTATION CALIBRATIONS
        //fullPath = Path.Combine(path, "ROT - " + Util.ObjectFullName(this.gameObject) + ".conf");
        //Debug.Log("Loading rotation calibration \"" + fullPath + "\"");
        //if (File.Exists(fullPath))
        //{
        //    string content = File.ReadAllText(fullPath);
        //    string[] parts = content.Split('|');
        //    if (parts.Length > 1)
        //    {
        //        this.transform.localRotation = Quaternion.Euler(float.Parse(parts[0].Replace(',', '.')), float.Parse(parts[1].Replace(',', '.')), float.Parse(parts[2].Replace(',', '.')));
        //    }
        //}
        //else
        //{
        //    Debug.LogWarning("Rotation calibration file could not be found");
        //}

#if UNITY_EDITOR
        if (!EditorApplication.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
#endif
    }
        public override void OnInspectorGUI()
        {
            if (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab)
            {
                return;
            }

            configuration = (ConfigurationScriptableObject)target;

            isDirty = false;

            licenseFold = EditorGUILayout.Foldout(licenseFold, "License Key Setting");
            if (licenseFold)
            {
                EditorGUILayout.LabelField("License key");
                string licenseKey = configuration.LicenseKey;
                configuration.LicenseKey = EditorGUILayout.TextArea(licenseKey, GUILayout.MaxHeight(40));
                EditorGUILayout.HelpBox("Please register your app at https://developer.maxst.com/.", MessageType.Info);
                EditorGUILayout.Space();
                if (string.Equals(licenseKey, configuration.LicenseKey) == false)
                {
                    isDirty = true;
                }
            }

            cameraFold = EditorGUILayout.Foldout(cameraFold, "Camera Settings");
            if (cameraFold)
            {
                CameraDevice.CameraType cameraType = configuration.CameraType;
                configuration.CameraType = (CameraDevice.CameraType)EditorGUILayout.EnumPopup("Mobile Camera Type", cameraType);
                EditorGUILayout.HelpBox("Camera settings in mobile app", MessageType.Info);
                EditorGUILayout.Space();
                if (string.Equals(cameraType, configuration.CameraType) == false)
                {
                    isDirty = true;
                }

                int webcamType = configuration.WebcamType;
                configuration.WebcamType = EditorGUILayout.Popup("Webcam Type", webcamType, LoadWebcamDeviceList());
                EditorGUILayout.HelpBox("Webcam settings in Editor mode.", MessageType.Info);
                EditorGUILayout.Space();
                if (string.Equals(webcamType, configuration.WebcamType) == false)
                {
                    isDirty = true;
                }

                CameraDevice.CameraResolution cameraResolution = configuration.CameraResolution;
                configuration.CameraResolution = (CameraDevice.CameraResolution)EditorGUILayout.EnumPopup("Camera Resolution", cameraResolution);
                EditorGUILayout.HelpBox("Please select a supported resolution.", MessageType.Info);
                EditorGUILayout.Space();
                if (string.Equals(cameraResolution, configuration.CameraResolution) == false)
                {
                    isDirty = true;
                }

                WearableCalibration.WearableType wearableType = configuration.WearableType;
                configuration.WearableType = (WearableCalibration.WearableType)EditorGUILayout.EnumPopup("Wearable Type", wearableType);
                EditorGUILayout.HelpBox("Please select a wearable type.", MessageType.Info);
                EditorGUILayout.Space();
                if (string.Equals(wearableType, configuration.WearableType) == false)
                {
                    isDirty = true;
                }
            }

            if (GUI.changed && isDirty)
            {
                EditorUtility.SetDirty(configuration);
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }
        public override void OnInspectorGUI()
        {
            var t        = target as AlembicExporter;
            var recorder = t.Recorder;
            var settings = recorder.Settings;
            var so       = serializedObject;

            bool dirty        = false;
            var  pathSettings = "m_recorder.m_settings.";

            // output path
            GUILayout.Space(5);
            EditorGUILayout.LabelField("Output Path", EditorStyles.boldLabel);
            {
                EditorGUILayout.BeginHorizontal();

                EditorGUI.BeginChangeCheck();
                settings.OutputPath = EditorGUILayout.TextField(settings.OutputPath);
                if (EditorGUI.EndChangeCheck())
                {
                    dirty = true;
                }

                if (GUILayout.Button("...", GUILayout.Width(24)))
                {
                    var dir      = "";
                    var filename = "";
                    try
                    {
                        dir      = Path.GetDirectoryName(settings.OutputPath);
                        filename = Path.GetFileName(settings.OutputPath);
                    }
                    catch (Exception) {}

                    var path = EditorUtility.SaveFilePanel("Output Path", dir, filename, "abc");
                    if (path.Length > 0)
                    {
                        settings.OutputPath = path;
                        dirty = true;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            GUILayout.Space(5);


            // alembic settings
            EditorGUILayout.LabelField("Alembic Settings", EditorStyles.boldLabel);
            {
#if !UNITY_EDITOR_LINUX
                var archiveProp = so.FindProperty(pathSettings + "conf.archiveType");
                using (var hScope = new EditorGUILayout.HorizontalScope())
                {
                    using (var propertyScope = new EditorGUI.PropertyScope(hScope.rect,
                                                                           new GUIContent(archiveProp.displayName), archiveProp))
                    {
                        using (var changeScope = new EditorGUI.ChangeCheckScope())
                        {
                            var val = EditorGUILayout.EnumPopup(propertyScope.content, (ArchiveType)archiveProp.intValue, null,
                                                                true);
                            if (changeScope.changed)
                            {
                                archiveProp.intValue = (int)(ArchiveType)val;
                            }
                        }
                    }
                }
#endif
                EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "conf.xformType"));
                var timeSamplingType = so.FindProperty(pathSettings + "conf.timeSamplingType");
                EditorGUILayout.PropertyField(timeSamplingType);
                if (timeSamplingType.intValue == (int)TimeSamplingType.Uniform)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "conf.frameRate"));
                    EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "fixDeltaTime"));
                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "conf.swapHandedness"));
                EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "conf.swapFaces"));
                EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "conf.scaleFactor"));
            }
            GUILayout.Space(5);


            // capture settings
            EditorGUILayout.LabelField("Capture Settings", EditorStyles.boldLabel);
            var scope = so.FindProperty(pathSettings + "scope");
            EditorGUILayout.PropertyField(scope);
            if (scope.intValue == (int)ExportScope.TargetBranch)
            {
                EditorGUI.indentLevel++;
                EditorGUI.BeginChangeCheck();
                settings.TargetBranch = EditorGUILayout.ObjectField("Target", settings.TargetBranch, typeof(GameObject), true) as GameObject;
                if (EditorGUI.EndChangeCheck())
                {
                    dirty = true;
                }
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "assumeNonSkinnedMeshesAreConstant"), new GUIContent("Static MeshRenderers"));
            GUILayout.Space(5);

            m_foldCaptureComponents = EditorGUILayout.Foldout(m_foldCaptureComponents, "Capture Components");
            if (m_foldCaptureComponents)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "captureMeshRenderer"), new GUIContent("MeshRenderer"));
                EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "captureSkinnedMeshRenderer"), new GUIContent("SkinnedMeshRenderer"));
                EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "captureCamera"), new GUIContent("Camera"));
                EditorGUI.indentLevel--;
            }

            m_foldMeshComponents = EditorGUILayout.Foldout(m_foldMeshComponents, "Mesh Components");
            if (m_foldMeshComponents)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "meshNormals"), new GUIContent("Normals"));
                EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "meshUV0"), new GUIContent("UV 0"));
                EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "meshUV1"), new GUIContent("UV 1"));
                EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "meshColors"), new GUIContent("Vertex Color"));
                EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "meshSubmeshes"), new GUIContent("Submeshes"));
                EditorGUI.indentLevel--;
            }
            {
                var m_captureOnStart = so.FindProperty("m_captureOnStart");
                EditorGUILayout.PropertyField(m_captureOnStart);
                if (m_captureOnStart.boolValue)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(so.FindProperty("m_ignoreFirstFrame"));
                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.PropertyField(so.FindProperty("m_maxCaptureFrame"));
            }
            GUILayout.Space(5);

            // misc settigs
            EditorGUILayout.LabelField("Misc", EditorStyles.boldLabel);
            {
                EditorGUILayout.PropertyField(so.FindProperty(pathSettings + "detailedLog"));
            }
            GUILayout.Space(10);

            so.ApplyModifiedProperties();
            if (dirty)
            {
                EditorUtility.SetDirty(target);
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
            }

            using (new EditorGUI.DisabledScope(!Application.isPlaying))
            {
                // capture control
                EditorGUILayout.LabelField("Capture Control", EditorStyles.boldLabel);
                if (recorder.Recording)
                {
                    if (GUILayout.Button("End Recording"))
                    {
                        t.EndRecording();
                    }
                }
                else
                {
                    if (GUILayout.Button("Begin Recording"))
                    {
                        t.BeginRecording();
                    }

                    if (GUILayout.Button("One Shot"))
                    {
                        t.OneShot();
                    }
                }
            }
        }
Пример #14
0
 public static void MarkSceneDirty()
 {
     EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
 }
Пример #15
0
    override public void OnInspectorGUI()
    {
        LightingSource2D script = target as LightingSource2D;

        EditorGUI.BeginDisabledGroup(true);
        EditorGUILayout.EnumPopup("Preset", LightingManager2D.Get().preset);
        EditorGUI.EndDisabledGroup();

        //script.lightingCollisionLayer = (LightingCollisionLayer)EditorGUILayout.EnumPopup("Collision Layer", script.lightingCollisionLayer);
        //script.lightingMaskLayer = (LightingMaskLayer)EditorGUILayout.EnumPopup("Mask Layer", script.lightingMaskLayer);
        script.layerCount = EditorGUILayout.IntField("Layer Count", script.layerCount);

        foldout = EditorGUILayout.Foldout(foldout, "Layers");
        if (foldout)
        {
            EditorGUI.indentLevel = EditorGUI.indentLevel + 1;
            for (int i = 0; i < script.layerCount; i++)
            {
                if (script.layerSetting.Length <= i)
                {
                    System.Array.Resize(ref script.layerSetting, i + 1);
                }
                if (script.layerSetting[i] == null)
                {
                    script.layerSetting[i] = new LayerSetting();
                }
                script.layerSetting[i].layerID        = (LightingLayer)EditorGUILayout.EnumPopup("ID", script.layerSetting[i].layerID);
                script.layerSetting[i].type           = (LightingLayerType)EditorGUILayout.EnumPopup("Type", script.layerSetting[i].type);
                script.layerSetting[i].renderingOrder = (LightRenderingOrder)EditorGUILayout.EnumPopup("Order", script.layerSetting[i].renderingOrder);
            }
            EditorGUI.indentLevel = EditorGUI.indentLevel - 1;
        }

        Color newColor = EditorGUILayout.ColorField("Color", script.lightColor);

        if (script.lightColor.Equals(newColor) == false)
        {
            newColor.a        = 1f;
            script.lightColor = newColor;

            LightingMainBuffer2D.ForceUpdate();
        }

        float newAlpha = EditorGUILayout.Slider("Alpha", script.lightAlpha, 0, 1);

        if (script.lightAlpha != newAlpha)
        {
            script.lightAlpha = newAlpha;

            LightingMainBuffer2D.ForceUpdate();
        }

        float newLightSize = EditorGUILayout.FloatField("Size", script.lightSize);

        if (newLightSize != script.lightSize)
        {
            script.lightSize = newLightSize;

            LightingMainBuffer2D.ForceUpdate();
        }

        switch (LightingManager2D.Get().fixedLightBufferSize)
        {
        case true:
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.EnumPopup("Buffer Size", LightingManager2D.Get().fixedLightTextureSize);
            EditorGUI.EndDisabledGroup();

            break;

        case false:
            script.textureSize = (LightingSourceTextureSize)EditorGUILayout.EnumPopup("Buffer Size", script.textureSize);
            break;
        }

        script.lightSprite = (LightingSource2D.LightSprite)EditorGUILayout.EnumPopup("Light Sprite", script.lightSprite);

        if (script.lightSprite == LightingSource2D.LightSprite.Custom)
        {
            Sprite newSprite = (Sprite)EditorGUILayout.ObjectField("Sprite", script.sprite, typeof(Sprite), true);
            if (newSprite != script.sprite)
            {
                script.sprite = newSprite;
                script.SetMaterial();

                LightingMainBuffer2D.ForceUpdate();
            }
        }
        else
        {
            if (script.sprite != LightingSource2D.GetDefaultSprite())
            {
                script.sprite = LightingSource2D.GetDefaultSprite();
                script.SetMaterial();

                LightingMainBuffer2D.ForceUpdate();
            }
        }

        script.enableCollisions = EditorGUILayout.Toggle("Apply Shadows & Masks", script.enableCollisions);

        script.rotationEnabled = EditorGUILayout.Toggle("Apply Rotation", script.rotationEnabled);

        script.additive = EditorGUILayout.Toggle("Apply Additive Shader", script.additive);

        if (script.additive)
        {
            script.additive_alpha = EditorGUILayout.Slider("Additive Alpha", script.additive_alpha, 0, 1);
        }

        script.eventHandling = EditorGUILayout.Toggle("Apply Event Handling", script.eventHandling);

        script.drawInsideCollider = EditorGUILayout.Toggle("Apply Light Inside Collider", script.drawInsideCollider);

        if (targets.Length > 1)
        {
            if (GUILayout.Button("Apply to All"))
            {
                foreach (Object obj in targets)
                {
                    LightingSource2D copy = obj as LightingSource2D;
                    if (copy == script)
                    {
                        continue;
                    }


                    copy.layerSetting[0].renderingOrder = script.layerSetting[0].renderingOrder;
                    copy.layerSetting[1].renderingOrder = script.layerSetting[1].renderingOrder;

                    copy.lightColor  = script.lightColor;
                    copy.lightAlpha  = script.lightAlpha;
                    copy.lightSize   = script.lightSize;
                    copy.textureSize = script.textureSize;

                    copy.enableCollisions = script.enableCollisions;
                    copy.rotationEnabled  = script.rotationEnabled;
                    copy.additive         = script.additive;
                    copy.additive_alpha   = script.additive_alpha;


                    copy.eventHandling      = script.eventHandling;
                    copy.drawInsideCollider = script.drawInsideCollider;

                    copy.lightSprite = script.lightSprite;
                    copy.sprite      = script.sprite;
                    copy.SetMaterial();
                }

                LightingMainBuffer2D.ForceUpdate();
            }
        }

        if (GUI.changed && EditorApplication.isPlaying == false)
        {
            EditorUtility.SetDirty(target);
            EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
        }
    }
Пример #16
0
        // NOTE(SpectatorQL): I know I could've used EditorGUILayout versions of these, I know, I'm dumb.
        // TODO(SpectatorQL): Sane way of doing this kind of stuff !!!
        void OnGUI()
        {
            int waveCount      = World.WaveData.MaxWave;
            int enemyTypeCount = (int)EnemyType.Count;

            if ((World.EnemyProbability.Values == null) || (World.EnemyProbability.Values.Length == 0))
            {
                World.EnemyProbability.Values = new float[waveCount * enemyTypeCount];
            }

            UpdateProbabilityOnSerializationChanges(World.EnemyProbability, waveCount, enemyTypeCount);


            float firstRowHeight = 24;

            Rect waveLabelRect = new Rect(0, 0, 80, firstRowHeight);

            EditorGUI.LabelField(waveLabelRect, $"Wave ({0}-{waveCount - 1})");

            Rect waveFieldRect = new Rect(waveLabelRect.width, 0, 32, firstRowHeight);

            Wave = EditorGUI.IntField(waveFieldRect, Wave);
            if (Wave >= waveCount)
            {
                Wave = waveCount - 1;
            }
            else if (Wave < 0)
            {
                Wave = 0;
            }

            Vector2 switchViewButtonSize     = new Vector2(80, firstRowHeight);
            Vector2 switchViewButtonPosition = new Vector2(position.width - switchViewButtonSize.x, 0);
            Rect    switchViewButtonRect     = new Rect(switchViewButtonPosition, switchViewButtonSize);
            string  switchViewButtonText     = "";

            if (DisplayedView == View.Wave)
            {
                switchViewButtonText = "Graph";
            }
            else if (DisplayedView == View.Graph)
            {
                switchViewButtonText = "Wave";
            }

            if (GUI.Button(switchViewButtonRect, switchViewButtonText))
            {
                if (DisplayedView == View.Wave)
                {
                    DisplayedView = View.Graph;
                }
                else if (DisplayedView == View.Graph)
                {
                    DisplayedView = View.Wave;
                }
            }


            Rect viewRect = new Rect(0, firstRowHeight, position.width, position.height - firstRowHeight);

            EditorGUI.DrawRect(viewRect, Color.gray);

            string[] enemyTypeNames = Enum.GetNames(typeof(EnemyType));
            float[]  probValues     = World.EnemyProbability.Values;
            if (DisplayedView == View.Wave)
            {
                float rowHeight = 32.0f;
                float rowStepY  = 32.0f;

                float enemyTypeLabelX     = 4.0f;
                float enemyTypeLabelY     = viewRect.position.y + rowStepY;
                float enemyTypeLabelWidth = 64.0f;

                float sliderX     = enemyTypeLabelWidth + 4.0f;
                float sliderY     = viewRect.position.y + rowStepY;
                float sliderWidth = 256.0f;

                for (int i = 0;
                     i < enemyTypeCount;
                     ++i)
                {
                    EditorGUI.LabelField(new Rect(enemyTypeLabelX, enemyTypeLabelY, enemyTypeLabelWidth, rowHeight), $"{enemyTypeNames[i]}");

                    int currentProbIndex = Wave * enemyTypeCount + i;
                    Debug.Assert(currentProbIndex < probValues.Length);
                    float prob = probValues[currentProbIndex];
                    prob = EditorGUI.Slider(new Rect(sliderX, sliderY, sliderWidth, rowHeight),
                                            prob,
                                            0, PTAEnemyProbability.PROBABILITY_TOTAL);

                    {
                        float probSum = 0.0f;
                        for (int j = 0;
                             j < enemyTypeCount;
                             ++j)
                        {
                            int probIndex = Wave * enemyTypeCount + j;
                            Debug.Assert(probIndex < probValues.Length);
                            probSum += probValues[probIndex];
                        }

                        if (probSum > PTAEnemyProbability.PROBABILITY_TOTAL)
                        {
                            prob = prob - (probSum - PTAEnemyProbability.PROBABILITY_TOTAL);
                            if (prob < 0.0f)
                            {
                                prob = 0.0f;
                            }
                        }
                    }

                    probValues[currentProbIndex] = prob;
                    sliderY         += rowStepY;
                    enemyTypeLabelY += rowStepY;
                }
            }
            else if (DisplayedView == View.Graph)
            {
                Rect yAxisRect = new Rect(viewRect.x, viewRect.y, 32, viewRect.height);

                float waveChunkX      = yAxisRect.width;
                float waveChunkWidth  = 32.0f;
                float graphRectWidth  = 0.0f;
                float graphRectHeight = viewRect.height;

                Vector2[] waveChunkPositions = new Vector2[waveCount];
                Vector2[] waveChunkSizes     = new Vector2[waveCount];
                for (int i = 0;
                     i < waveCount;
                     ++i)
                {
                    waveChunkPositions[i].x = waveChunkX;
                    waveChunkPositions[i].y = viewRect.y;
                    waveChunkSizes[i].x     = waveChunkWidth;
                    waveChunkSizes[i].y     = graphRectHeight;

                    waveChunkX     += waveChunkWidth;
                    graphRectWidth += waveChunkWidth;
                }

                Rect graphRect = new Rect(viewRect.x, viewRect.y, graphRectWidth, graphRectHeight);


                ScrollPosition = GUI.BeginScrollView(viewRect, ScrollPosition, graphRect);
                {
                    EditorGUI.DrawRect(yAxisRect, Color.gray);
                    for (float i = 1.0f;
                         i >= 0;
                         i -= 0.1f)
                    {
                        // NOTE(SpectatorQL): Need to do this because labels are drawn in such a way that
                        // the text of a particular label doesn't line up exactly with points on the graph.
                        float labelOffsetY   = -8.0f;
                        float y              = ((1 - i) * yAxisRect.height) + yAxisRect.y + labelOffsetY;
                        float height         = yAxisRect.height / 10.0f;
                        Rect  yAxisLabelRect = new Rect(yAxisRect.x, y, yAxisRect.width, height);
                        EditorGUI.LabelField(yAxisLabelRect, $"{i.ToString("0.0")}");
                    }


                    Rect[] waveChunkRects = new Rect[waveCount];
                    for (int i = 0;
                         i < waveCount;
                         ++i)
                    {
                        waveChunkRects[i].x      = waveChunkPositions[i].x;
                        waveChunkRects[i].y      = waveChunkPositions[i].y;
                        waveChunkRects[i].width  = waveChunkSizes[i].x;
                        waveChunkRects[i].height = waveChunkSizes[i].y;
#if true
                        Color debugChunkColor = new Color();
                        debugChunkColor.a = 1.0f;
                        debugChunkColor.r = (float)i / (waveCount - 1);
                        debugChunkColor.g = (float)i / (waveCount - 1);
                        debugChunkColor.b = (float)i / (waveCount - 1);
                        EditorGUI.DrawRect(waveChunkRects[i], debugChunkColor);
#else
                        EditorGUI.DrawRect(waveChunkRects[i], Color.gray);
#endif

                        Rect labelRect = new Rect(waveChunkRects[i].x,
                                                  waveChunkRects[i].y + waveChunkRects[i].height,
                                                  waveChunkRects[i].width,
                                                  viewRect.height - waveChunkRects[i].height);
                        EditorGUI.LabelField(labelRect, $"{i}");
                    }


                    Color[] enemyTypeColors = new Color[enemyTypeCount];
                    for (int i = 0;
                         i < enemyTypeCount;
                         ++i)
                    {
                        enemyTypeColors[i].a = 1.0f;
                        enemyTypeColors[i].r = 1.0f;
                        enemyTypeColors[i].g = (float)i / enemyTypeCount;
                    }

                    Color originalHandlesColor = Handles.color;
                    for (int i = 0;
                         i < waveCount - 1;
                         ++i)
                    {
                        for (int j = 0;
                             j < enemyTypeCount;
                             ++j)
                        {
                            Handles.color = enemyTypeColors[j];

                            int probIndex     = i * enemyTypeCount + j;
                            int nextProbIndex = probIndex + enemyTypeCount;
                            Debug.Assert(probIndex < probValues.Length);

                            // NOTE(SpectatorQL): For down-to-up drawing.
                            float f1 = 1 - probValues[probIndex];
                            float f2 = 1 - probValues[nextProbIndex];

                            float   xOffset = 4.5f;
                            float   x1      = waveChunkRects[i].x + xOffset;
                            float   x2      = waveChunkRects[i + 1].x + xOffset;
                            float   y1      = (waveChunkRects[i].height * f1) + waveChunkRects[i].y;
                            float   y2      = (waveChunkRects[i + 1].height * f2) + waveChunkRects[i + 1].y;
                            Vector2 currentWaveProbPoint = new Vector2(x1, y1);
                            Vector2 nextWaveProbPoint    = new Vector2(x2, y2);

                            Handles.DrawLine(currentWaveProbPoint, nextWaveProbPoint);
                            float pointSize = 3.25f;
                            Handles.CircleHandleCap(0, currentWaveProbPoint, Quaternion.identity, pointSize, EventType.Repaint);
                            Handles.CircleHandleCap(0, nextWaveProbPoint, Quaternion.identity, pointSize, EventType.Repaint);
                        }
                    }
                    Handles.color = originalHandlesColor;
                }
                GUI.EndScrollView();
            }

            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
Пример #17
0
    //Forces unity to save our changes made to the scene
    private void MarkSceneAsDirty()
    {
        Scene activeScene = SceneManager.GetActiveScene();

        EditorSceneManager.MarkSceneDirty(activeScene);
    }
Пример #18
0
        void OnGUI()
        {
            m_TimeSinceLastRepaint = 0;
            CompositionManager compositor = CompositionManager.GetInstance();
            bool enableCompositor         = false;

            if (compositor)
            {
                enableCompositor = compositor.enabled;
            }

            bool enableCompositorCached = enableCompositor;

            enableCompositor = EditorGUILayout.Toggle(Styles.k_EnableCompositor, enableCompositor);

            // Track if the user changed the compositor enable state and mark the scene dirty if necessary
            if (enableCompositorCached != enableCompositor && compositor != null)
            {
                EditorUtility.SetDirty(compositor);
            }

            if (compositor == null && enableCompositor)
            {
                Debug.Log("The scene does not have a compositor. Creating a new one with the default configuration.");
                GameObject go = new GameObject("HDRP Compositor")
                {
                    hideFlags = HideFlags.HideInHierarchy
                };
                compositor = go.AddComponent <CompositionManager>();

                // Mark as dirty, so if the user closes the scene right away, the change will be saved.
                EditorUtility.SetDirty(compositor);

                // Now add the default configuration
                CompositionUtils.LoadDefaultCompositionGraph(compositor);
                CompositionUtils.LoadOrCreateCompositionProfileAsset(compositor);
                compositor.SetupCompositionMaterial();
                CompositionUtils.SetDefaultCamera(compositor);
                CompositionUtils.SetDefaultLayers(compositor);
            }

            if (compositor)
            {
                compositor.enabled = enableCompositor;
            }
            else
            {
                return;
            }

            if (compositor && !compositor.enabled)
            {
                if (GUILayout.Button(new GUIContent(Styles.k_RemoveCompositor)))
                {
                    if (compositor.outputCamera)
                    {
                        if (compositor.outputCamera.name == CompositionUtils.k_DefaultCameraName)
                        {
                            var cameraData = compositor.outputCamera.GetComponent <HDAdditionalCameraData>();
                            if (cameraData != null)
                            {
                                CoreUtils.Destroy(cameraData);
                            }
                            CoreUtils.Destroy(compositor.outputCamera.gameObject);
                            CoreUtils.Destroy(compositor.outputCamera);
                            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                        }
                    }

                    CoreUtils.Destroy(compositor);
                    return;
                }
            }

            if (compositor.profile == null)
            {
                // The compositor was loaded, but there was no profile (someone deleted the asset from disk?), so create a new one
                CompositionUtils.LoadOrCreateCompositionProfileAsset(compositor);
                compositor.SetupCompositionMaterial();
                return;
            }

            if (compositor.shader != null)
            {
                // keep track of shader graph changes: when the user saves a graph, we should load/reflect any new shader properties
                GraphData.onSaveGraph += MarkShaderAsDirty;
            }

            if (m_Editor == null || m_Editor.target == null || m_Editor.isDirty || m_RequiresRedraw)
            {
                m_Editor         = (CompositionManagerEditor)Editor.CreateEditor(compositor);
                m_RequiresRedraw = false;
            }

            m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition);
            using (new EditorGUI.DisabledScope(!compositor.enabled))
            {
                if (m_Editor)
                {
                    m_Editor.OnInspectorGUI();
                }
            }
            GUILayout.EndScrollView();
        }
Пример #19
0
    private void DrawSettings()
    {
        PupilSettings pupilSettings = PupilTools.Settings;

        GUILayout.Space(10);

        // test for changes in exposed values
        EditorGUI.BeginChangeCheck();
        pupilTracker.SettingsTab = GUILayout.Toolbar(pupilTracker.SettingsTab, new string[] {
            "pupil app",
            "calibration",
            "recording"
        }, GUILayout.Height(30));
        ////////INPUT FIELDS////////
        switch (pupilTracker.SettingsTab)
        {
        case 0:        //PUPIL APP
            if (PupilTools.Settings.DataProcessState == PupilSettings.EStatus.Calibration)
            {
                GUI.enabled = false;
            }

            GUILayout.Space(10);

            AutoRunLayout();

            GUILayout.Space(20);

            ////////////////////////////CONNECTION MODE////////////////////////////
            EditorGUI.BeginChangeCheck();
            //GUI.color = new Color (.7f, .7f, .7f, 1f);

            PupilTools.Settings.connection.isLocal = Convert.ToBoolean(GUILayout.Toolbar(Convert.ToInt32(PupilTools.Settings.connection.isLocal), new string[] {
                "Remote",
                "Local"
            }, GUILayout.Height(30), GUILayout.MinWidth(25)));
            //pupilTracker.customInspector.connectionMode = GUILayout.Toolbar (pupilTracker.customInspector.connectionMode, new string[]{ "Local", "Remote" }, GUILayout.Height (30), GUILayout.MinWidth (25));
            GUI.color = Color.white;
            if (EditorGUI.EndChangeCheck())
            {
                if (PupilTools.Settings.connection.isLocal)
                {
                    tempServerIP = PupilTools.Settings.connection.IP;
                    PupilTools.Settings.connection.IP = "127.0.0.1";
                }
                else
                {
                    PupilTools.Settings.connection.IP = tempServerIP;
                }
            }

            ////////////////////////////CONNECTION MODE////////////////////////////
            GUILayout.Space(5);
            if (PupilTools.Settings.connection.isLocal)              //LOCAL CONNECTION MODE//
            ////////////////////////////PUPIL APP PATH////////////////////////////
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("path : ", pupilSettings.GUIStyles[5], GUILayout.MinWidth(50));

                PupilTools.Settings.pupilServiceApp.servicePath = EditorGUILayout.TextArea(PupilTools.Settings.pupilServiceApp.servicePath, pupilSettings.GUIStyles[6], GUILayout.MinWidth(100), GUILayout.Height(22));
                if (GUILayout.Button("Browse"))
                {
                    PupilTools.Settings.pupilServiceApp.servicePath = EditorUtility.OpenFilePanel("Select Pupil service application file", PupilTools.Settings.pupilServiceApp.servicePath, "exe");
                }
                GUILayout.EndHorizontal();
                ////////////////////////////PUPIL APP PATH////////////////////////////
            }

            if (pupilSettings.customGUIVariables.bools.isAdvanced)             //ADVANCED SETTING

            ////////////////////////////SERVICE PORT////////////////////////////
            ///
            {
                GUILayout.BeginHorizontal();                 //---------HORIZONTAL GROUP---------//
                //
                GUILayout.Label("Service Port : ", pupilSettings.GUIStyles[3], GUILayout.MinWidth(50));
                PupilTools.Settings.connection.PORT = EditorGUILayout.IntField(PupilTools.Settings.connection.PORT, pupilSettings.GUIStyles[4], GUILayout.MinWidth(100), GUILayout.Height(22));
                //
                GUILayout.EndHorizontal();                 //---------HORIZONTAL GROUP\---------//
                ///
                ////////////////////////////SERVICE PORT\////////////////////////////
                base.OnInspectorGUI();
                GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); //Separator Line
            }                                                                        //ADVANCED SETTING\

            if (!PupilTools.Settings.connection.isLocal)                             //---------REMOTE CONNECTION MODE---------//



            {
                GUILayout.Space(5);

                ////////////////////////////SERVER IP ADDRESS////////////////////////////
                ///

                GUILayout.BeginHorizontal();                 //---------HORIZONTAL GROUP---------//
                //
                GUILayout.Label("IP : ", pupilSettings.GUIStyles[5], GUILayout.MinWidth(50));
                //

//				pupilTracker.Settings = (PupilSettings)EditorGUILayout.ObjectField (pupilTracker.Settings);
//				pupilTracker.Settings.a = EditorGUILayout.TextArea (pupilTracker.Settings.a, pupilTracker.Styles[8], GUILayout.MinWidth (50), GUILayout.Height (22));
                PupilTools.Settings.connection.IP = EditorGUILayout.TextArea(PupilTools.Settings.connection.IP, pupilSettings.GUIStyles[4], GUILayout.MinWidth(50), GUILayout.Height(22));
                if (GUILayout.Button("Default"))
                {
                    PupilTools.Settings.connection.IP = "127.0.0.1";
                    Repaint();
                    GUI.FocusControl("");
                }
                //
                GUI.enabled = true;
                //
                GUILayout.EndHorizontal();                 //---------HORIZONTAL GROUP\---------//
                ///
                ////////////////////////////SERVER IP ADDRESS\////////////////////////////


                GUI.enabled = true;
            }            //---------REMOTE CONNECTION MODE\---------//


            break;

        case 1:        //CALIBRATION


//			GUILayout.Space (20);
//
//			////////////////////////////2D-3D TOGGLE BAR////////////////////////////
//			EditorGUI.BeginChangeCheck ();
//			var calibrationMode = (Calibration.Mode)GUILayout.Toolbar ((int)pupilSettings.calibration.currentMode, new string[] {
//				"2D",
//				"3D"
//			});
//			if (calibrationMode != pupilSettings.calibration.currentMode)
//			{
//				pupilSettings.calibration.SetMode (calibrationMode);
//			}
//			GUI.enabled = true;
//			EditorGUI.EndChangeCheck ();
//			////////////////////////////2D-3D TOGGLE BAR////////////////////////////

            ////////////////////////////CALIBRATION DEBUG MODE////////////////////////////
            if (PupilTools.Settings.DataProcessState == PupilSettings.EStatus.Calibration || !isEyeProcessConnected || (int)pupilSettings.calibration.currentMode != 1)
            {
            }
            else
            {
                //GUI.enabled = false;

                EditorGUI.BeginChangeCheck();

                pupilSettings.debugView.active = GUILayout.Toggle(pupilSettings.debugView.active, "Calibration Debug Mode", "Button");
                GUI.enabled = true;
                if (EditorGUI.EndChangeCheck())
                {
                    if (pupilSettings.debugView.active)
                    {
                        if (pupilTracker.OperatorMonitorProperties [0].OperatorCamera != null)
                        {
                            OperatorMonitor.Instance.ExitOperatorMonitor();
                        }
                        pupilTracker.debugInstance.StartCalibrationDebugView();
                    }
                    else
                    {
                        pupilTracker.debugInstance.CloseCalibrationDebugView();
                    }
                }
            }

            if (pupilSettings.debugView.active)
            {
                //				pupilTracker.calibrationDebugCamera = (PupilGazeTracker.CalibrationDebugCamera) EditorGUILayout.EnumPopup (pupilTracker.calibrationDebugCamera);
                GUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                pupilTracker.debugInstance.DebugViewVariables.isDrawLines  = GUILayout.Toggle(pupilTracker.debugInstance.DebugViewVariables.isDrawLines, " Draw Debug Lines ", "Button");
                pupilTracker.debugInstance.DebugViewVariables.isDrawPoints = GUILayout.Toggle(pupilTracker.debugInstance.DebugViewVariables.isDrawPoints, " Draw Debug Points ", "Button");
                if (EditorGUI.EndChangeCheck())
                {
                    pupilTracker.debugInstance.SetDrawCalibrationPointCloud(pupilTracker.debugInstance.DebugViewVariables.isDrawPoints);
                    pupilTracker.debugInstance.SetDrawCalibrationLines(pupilTracker.debugInstance.DebugViewVariables.isDrawLines);
                }
                GUILayout.EndHorizontal();
            }

            GUI.enabled = true;
//			////////////////////////////CALIBRATION DEBUG MODE////////////////////////////
//
//			GUILayout.Space (20);
//
//			GUILayout.BeginHorizontal ();////////////////////HORIZONTAL////////////////////
//			GUILayout.Label ("Samples per depth", pupilSettings.GUIStyles[3], GUILayout.MinWidth (35));
//			pupilSettings.calibration.currentCalibrationType.samplesPerDepth = EditorGUILayout.IntSlider (pupilSettings.calibration.currentCalibrationType.samplesPerDepth, 1, 120, GUILayout.ExpandWidth(true));
//			GUILayout.EndHorizontal ();////////////////////HORIZONTAL////////////////////

            GUILayout.Space(10);             //------------------------------------------------------------//

            if (pupilSettings.customGUIVariables.bools.isAdvanced)
            {
                base.OnInspectorGUI();
            }
            break;

        case 2:        //RECORDING

            GUILayout.Space(20);

            GUILayout.BeginHorizontal();
            PupilTools.Settings.recorder.resolution = (FFmpegOut.FFmpegPipe.Resolution)EditorGUILayout.EnumPopup(PupilTools.Settings.recorder.resolution);
            PupilTools.Settings.recorder.codec      = (FFmpegOut.FFmpegPipe.Codec)EditorGUILayout.EnumPopup(PupilTools.Settings.recorder.codec);        //  GUILayout.Toolbar (pupilTracker.Codec, new string[] {
            GUILayout.EndHorizontal();

//			GUILayout.BeginHorizontal ();
//			PupilTools.Settings.recorder.isFixedRecordingLength = GUILayout.Toggle (PupilTools.Settings.recorder.isFixedRecordingLength, "fixed length", "Button", GUILayout.Width (90));
//			if (PupilTools.Settings.recorder.isFixedRecordingLength) {
//				PupilTools.Settings.recorder.recordingLength = EditorGUILayout.FloatField (PupilTools.Settings.recorder.recordingLength);
//			}
//			GUILayout.EndHorizontal ();

            GUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            PupilTools.Settings.recorder.isCustomPath = GUILayout.Toggle(PupilTools.Settings.recorder.isCustomPath, "CustomPath", "Button", GUILayout.Width(90));
            if (EditorGUI.EndChangeCheck())
            {
                if (PupilTools.Settings.recorder.isCustomPath)
                {
                    PupilTools.Settings.recorder.filePath = EditorUtility.OpenFolderPanel("Select the output folder", PupilTools.Settings.recorder.filePath, "");
                }
            }
            if (PupilTools.Settings.recorder.isCustomPath)
            {
                GUIStyle centeredStyle = new GUIStyle(GUI.skin.textField);
                centeredStyle.alignment               = TextAnchor.MiddleCenter;
                centeredStyle.margin                  = new RectOffset(0, 0, 3, 0);
                centeredStyle.fixedHeight             = 20;
                PupilTools.Settings.recorder.filePath = GUILayout.TextField(PupilTools.Settings.recorder.filePath, centeredStyle);
                if (GUILayout.Button("Browse", GUILayout.Width(60)))
                {
                    PupilTools.Settings.recorder.filePath = EditorUtility.OpenFolderPanel("Select the output folder", PupilTools.Settings.recorder.filePath, "");
                }
            }
            GUILayout.EndHorizontal();

            break;
        }


        //if change found set scene as dirty, so user will have to save changed values.
        if (EditorGUI.EndChangeCheck() && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }

        GUILayout.Space(10);
    }
Пример #20
0
 public static void SetObjectDirty(GameObject obj)
 {
     EditorUtility.SetDirty(obj);
     EditorSceneManager.MarkSceneDirty(obj.scene);
 }
Пример #21
0
        // Only works with unity 5.3+
        public static void SaveActiveSceneChanges(this Editor editor)
        {
            var activeScene = SceneManager.GetActiveScene();

            EditorSceneManager.MarkSceneDirty(activeScene);
        }
Пример #22
0
    public override void OnInspectorGUI()
    {
        UCNetwork cave = target as UCNetwork;

        cave.head = (HeadConfiguration)EditorGUILayout.ObjectField("Head", cave.head, typeof(HeadConfiguration), true);

        if (GUILayout.Button("Save Launch Script"))
        {
            string launchScript = cave.GenerateLaunchScript();
            string savePath     = EditorUtility.SaveFilePanel("Save Launch Script", "./", Application.productName + ".ps1", "ps1");
            if (savePath != null && savePath.Length != 0)
            {
                System.IO.File.WriteAllText(savePath, launchScript);
                Debug.Log("Saved launch script to " + savePath);
            }
            else
            {
                Debug.Log("Didn't save file (no path given)");
            }
        }
        List <PhysicalDisplay>              displays   = GetAllDisplays();
        List <PhysicalDisplayManager>       managers   = GetAllManagers();
        Dictionary <string, List <object> > havingName = new Dictionary <string, List <object> >();
        List <string> machines = new List <string>();

        for (int i = 0; i < managers.Count; i++)
        {
            if (!havingName.ContainsKey(managers[i].machineName))
            {
                havingName[managers[i].machineName] = new List <object> {
                    managers[i]
                };
                machines.Add(managers[i].machineName);
            }
            else
            {
                havingName[managers[i].machineName].Add(managers[i].gameObject);
            }
        }
        for (int i = 0; i < displays.Count; i++)
        {
            if (displays[i].manager == null)
            {
                if (displays[i].machineName == null || !havingName.ContainsKey(displays[i].machineName))
                {
                    havingName[displays[i].machineName] = new List <object> {
                        displays[i]
                    };
                    machines.Add(displays[i].machineName);
                }
                else
                {
                    havingName[displays[i].machineName].Add(displays[i].gameObject);
                }
            }
        }

        //List<string> errors = new List<string>();
        //foreach(var kvp in havingName) {
        //    if(kvp.Value.Count > 1) {
        //        errors.Add("These GameObjects have conflicting use of machine name " + kvp.Key + " :");
        //        foreach(var obj in kvp.Value) {
        //            errors.Add("\t" + Util.ObjectFullName(obj));
        //        }
        //    }
        //}

        //if(errors.Count != 0) {
        //    GUIStyle colored = new GUIStyle();
        //    colored.fontSize = 18;
        //    colored.normal.textColor = new Color(0.7f, 0, 0);
        //    EditorGUILayout.LabelField("WARNING: Invalid CAVE Configuration", colored);
        //    foreach (var er in errors) {
        //        EditorGUILayout.LabelField(er);
        //    }
        //    return;
        //}

        //if (selectedIndex >= machines.Count) selectedIndex = 0;
        //selectedIndex = EditorGUILayout.Popup("Selected Machine", selectedIndex, machines.ToArray(), EditorStyles.popup);

        /*
         * List<object> selectedObjs = havingName[machines[selectedIndex]];
         * Dictionary<int, List<KeyValuePair<string, RectInt>>> usingDisplay = new Dictionary<int, List<KeyValuePair<string, RectInt>>>();
         * for (int i = 0; i < selectedObjs.Count; i++) {
         *  int displayIndex = -1;
         *  List<RectInt> viewports = new List<RectInt>();
         *  if (selectedObjs[i] is PhysicalDisplayManager) {
         *      displayIndex = (selectedObjs[i] as PhysicalDisplayManager).displayNumber;
         *      foreach (PhysicalDisplay disp in (selectedObjs[i] as PhysicalDisplayManager).displays) {
         *          viewports.Add(new KeyValuePair<string, RectInt>());
         *      }
         *  } else if (selectedObjs[i] is PhysicalDisplay) {
         *      if ((selectedObjs[i] as PhysicalDisplay).exclusiveFullscreen) {
         *          displayIndex = (selectedObjs[i] as PhysicalDisplay).display;
         *      }
         *  }
         *  if (usingDisplay.ContainsKey(displayIndex)) {
         *      usingDisplay[displayIndex].Add(sele)
         *  } else {
         *      usingDisplay[displayIndex] = new List<RectInt> { }
         *  }
         * }
         * for (int i = 0; i < selectedObjs.Count; i++) {
         *  selectedObjs[i].GetComponent < PhysicalDisplayManager >
         *  int dispIndex = managers[i].displayNumber;
         *
         *  EditorGUILayout.LabelField("Display " + dispIndex + " :");
         *  GUILayout.BeginHorizontal(EditorStyles.helpBox);
         *  Rect drawSpace = GUILayoutUtility.GetRect(10, 10000, 200, 200);
         *  if (Event.current.type == EventType.Repaint) {
         *      GUI.BeginClip(drawSpace);
         *      GL.PushMatrix();
         *
         *      //GL.Viewport(drawSpace);
         *      //GL.Clear(true, false, Color.black);
         *      //material.SetPass(0);
         *
         *      //GL.Begin(GL.QUADS);
         *      //GL.Color(Color.white);
         *      //    GL.Vertex3(0,               0,                  0);
         *      //    GL.Vertex3(drawSpace.width, 0,                  0);
         *      //    GL.Vertex3(drawSpace.width, drawSpace.height,   0);
         *      //    GL.Vertex3(0,               drawSpace.height,   0);
         *      //GL.End();
         *
         *      TextAtPosition(0, 0, 12, "long ass string");
         *
         *      GL.PopMatrix();
         *      GUI.EndClip();
         *  }
         *  GUILayout.EndHorizontal();
         * }*/

        if (GUI.changed)
        {
            EditorUtility.SetDirty(cave);
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
    }
Пример #23
0
        public override void OnInspectorGUI()
        {
            NVRCollisionSoundController controller = (NVRCollisionSoundController)target;

            if (hasReloaded == false)
            {
                DidReloadScripts();
            }

            if (waitingForReload)
            {
                HasWaitedLongEnough();
            }

            bool installFMOD    = false;
            bool isFMODEnabled  = controller.SoundEngine == NVRCollisionSoundProviders.FMOD;
            bool isUnityEnabled = controller.SoundEngine == NVRCollisionSoundProviders.Unity;
            bool enableFMOD     = controller.SoundEngine == NVRCollisionSoundProviders.FMOD;
            bool enableUnity    = controller.SoundEngine == NVRCollisionSoundProviders.Unity;

            EditorGUILayout.BeginHorizontal();
            if (hasFMODSDK == false)
            {
                using (new EditorGUI.DisabledScope(hasFMODSDK == false)) {
                    EditorGUILayout.Toggle("Use FMOD", false);
                }
                installFMOD = GUILayout.Button("Install FMOD");
            }
            else
            {
                enableFMOD = EditorGUILayout.Toggle("Use FMOD", enableFMOD);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            enableUnity = EditorGUILayout.Toggle("Use Unity Sound", enableUnity);
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10);

            if (enableFMOD == false && isFMODEnabled)
            {
                RemoveDefine(FMODDefine);
                controller.SoundEngine = NVRCollisionSoundProviders.None;
            }
            else if (enableFMOD && isFMODEnabled == false)
            {
                AddDefine(FMODDefine);
                controller.SoundEngine = NVRCollisionSoundProviders.FMOD;
            }

            if (enableUnity == false && isUnityEnabled)
            {
                RemoveDefine(FMODDefine);
                controller.SoundEngine = NVRCollisionSoundProviders.None;
            }
            else if (enableUnity && isUnityEnabled == false)
            {
                RemoveDefine(FMODDefine);
                controller.SoundEngine = NVRCollisionSoundProviders.Unity;
            }

            if (installFMOD)
            {
                Application.OpenURL("http://www.fmod.org/download/");
            }

            DrawDefaultInspector();

            if (waitingForReload || string.IsNullOrEmpty(progressBarMessage) == false)
            {
                DisplayProgressBar();
            }

            if (GUI.changed)
            {
                if (Application.isPlaying == false)
                {
                    EditorUtility.SetDirty(target);
                    EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                }
            }
        }
Пример #24
0
 static void MarkSceneDirty()
 {
     EditorSceneManager.MarkSceneDirty(UnityEngine.SceneManagement.SceneManager.GetActiveScene());
 }
Пример #25
0
        public override void Run()
        {
            var editorConnectionTestCollector = RemoteTestRunController.instance;

            editorConnectionTestCollector.hideFlags = HideFlags.HideAndDontSave;
            editorConnectionTestCollector.Init(m_TargetPlatform, m_HeartbeatTimeout);

            var remotePlayerLogController = RemotePlayerLogController.instance;

            remotePlayerLogController.hideFlags = HideFlags.HideAndDontSave;

            using (var settings = new PlayerLauncherContextSettings(m_OverloadTestRunSettings))
            {
                m_SceneName = CreateSceneName();
                var    scene     = PrepareScene(m_SceneName);
                string scenePath = scene.path;

                var filter          = m_Settings.BuildNUnitFilter();
                var runner          = LoadTests(filter);
                var exceptionThrown = ExecutePreBuildSetupMethods(runner.LoadedTest, filter);
                if (exceptionThrown)
                {
                    ReopenOriginalScene(m_Settings.originalScene);
                    AssetDatabase.DeleteAsset(m_SceneName);
                    CallbacksDelegator.instance.RunFailed("Run Failed: One or more errors in a prebuild setup. See the editor log for details.");
                    return;
                }

                EditorSceneManager.MarkSceneDirty(scene);
                EditorSceneManager.SaveScene(scene);

                var playerBuildOptions = GetBuildOptions(scenePath);

                var success = BuildAndRunPlayer(playerBuildOptions);

                editorConnectionTestCollector.PostBuildAction();
                ExecutePostBuildCleanupMethods(runner.LoadedTest, filter);

                ReopenOriginalScene(m_Settings.originalScene);
                AssetDatabase.DeleteAsset(m_SceneName);

                if (!success)
                {
                    editorConnectionTestCollector.CleanUp();
                    ScriptableObject.DestroyImmediate(editorConnectionTestCollector);
                    Debug.LogError("Player build failed");
                    throw new TestLaunchFailedException("Player build failed");
                }

                if ((playerBuildOptions.BuildPlayerOptions.options & BuildOptions.AutoRunPlayer) != 0)
                {
                    editorConnectionTestCollector.PostSuccessfulBuildAction();
                    editorConnectionTestCollector.PostSuccessfulLaunchAction();
                }

                var runSettings = m_OverloadTestRunSettings as PlayerLauncherTestRunSettings;
                if (success && runSettings != null && runSettings.buildOnly)
                {
                    EditorUtility.RevealInFinder(playerBuildOptions.BuildPlayerOptions.locationPathName);
                }
            }
        }
Пример #26
0
    public override void OnInspectorGUI()
    {
        var myScript = target as CameraScript;

        UpdateLayerInputs();

        EditorGUILayout.BeginVertical("Box");
        myScript.inputEditorFPS = GUILayout.Toolbar(myScript.inputEditorFPS, new string[] { "Third Person View", "First Person View" });

        switch (myScript.inputEditorFPS)
        {
        case 0:
            myScript.FPS = false;
            break;

        case 1:
            myScript.FPS = true;
            break;
        }

        if (myScript.FPS)
        {
            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("First person view properties to position and rotate camera inside the drone.", MessageType.None);
            // EditorGUILayout.Space();
            //   myScript.FPS = EditorGUILayout.Toggle(new GUIContent("FPS (ON)"), myScript.FPS);
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            myScript.positionInsideDrone = EditorGUILayout.Vector3Field(new GUIContent("Position inside drone", "This will move cameras local position inside drone."), myScript.positionInsideDrone);
            myScript.rotationInsideDrone = EditorGUILayout.Vector3Field(new GUIContent("Rotation inside drone", "This will give the camera extra X (up/down) tilt when in POV mode, so when you move forward your camera view is straight."), myScript.rotationInsideDrone);
            myScript.fpsViewMask         = EditorGUILayout.MaskField(new GUIContent("FPS View Mask", "Layers that we wish to see in the FPS mode... suggestion to disable body part and see only propelers"), myScript.fpsViewMask, optionsFPS);
            myScript.fpsFieldOfView      = EditorGUILayout.FloatField(new GUIContent("Field Of View", "Camera field of view"), myScript.fpsFieldOfView);
        }
        else
        {
            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("Third person view properties to position and rotate camera behind the drone.", MessageType.None);
            // EditorGUILayout.Space();
            //  myScript.FPS = EditorGUILayout.Toggle(new GUIContent("FPS (OFF)"), myScript.FPS);
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            myScript.positionBehindDrone      = EditorGUILayout.Vector3Field(new GUIContent("Position behind drone", "Position of the camera behind the drone."), myScript.positionBehindDrone);
            myScript.cameraFollowPositionTime = EditorGUILayout.Slider(new GUIContent("Camera follow position time", "How fast the camera will follow drone position. (The lower the value the faster it will follow)"), myScript.cameraFollowPositionTime, 0.0f, 0.1f);
            myScript.extraTilt      = EditorGUILayout.FloatField(new GUIContent("Extra camera tilt when moving", "Value where if the camera/drone is moving upwards will raise the camera view upward to get a better look at what is above, same goes when going downwards."), myScript.extraTilt);
            myScript.tpsLayerMask   = EditorGUILayout.MaskField(new GUIContent("TPS View Mask", "Layers that we wish to see in the FPS mode... suggestion to disable body part and see only propelers"), myScript.tpsLayerMask, optionsTPS);
            myScript.tpsFieldOfView = EditorGUILayout.FloatField(new GUIContent("Field Of View", "Camera field of view"), myScript.tpsFieldOfView);
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            myScript.freeMouseMovement = EditorGUILayout.Toggle(new GUIContent("Free Mouse Look", "Allows to freely view around the drone with your mouse and not depending on drone look rotation."), myScript.freeMouseMovement);
            EditorGUILayout.Space();
            if (myScript.freeMouseMovement)
            {
                myScript.useJoystickFreeMovementOnly = EditorGUILayout.Toggle(new GUIContent("Toggle joystick only free look", "Allows to freely view around the drone with your joystick and not depending on drone look rotation."), myScript.useJoystickFreeMovementOnly);

                EditorGUILayout.BeginVertical("Box");
                if (myScript.useJoystickFreeMovementOnly == false)
                {
                    myScript.mouseSensitvity = EditorGUILayout.FloatField(new GUIContent("Mouse Sensitivity", "Value that will determine how fast your free look mouse will behave."), myScript.mouseSensitvity);
                    myScript.mouseFollowTime = EditorGUILayout.FloatField(new GUIContent("Mouse Follow Time", "Value that will follow the camera view behind the mouse movement.(The lower the value, the faster it will follow mouse movement)"), myScript.mouseFollowTime);
                    EditorGUILayout.Space();
                    EditorGUILayout.Space();
                    EditorGUILayout.HelpBox("Mouse Input", MessageType.Info);
                    myScript.mouse_X_axisName = EditorGUILayout.TextField(new GUIContent("Mouse X axis name", "Name of the mouse X axis that is connected to mouse movement."), myScript.mouse_X_axisName);
                    myScript.mouse_Y_axisName = EditorGUILayout.TextField(new GUIContent("Mouse Y axis name", "Name of the mouse Y axis that is connected to mouse movement."), myScript.mouse_Y_axisName);
                }
                EditorGUILayout.HelpBox("Joystick Input", MessageType.Info);
                myScript.dPad_X_axisName = EditorGUILayout.TextField(new GUIContent("Joystick axis for the X axis", "Name of the joystick input, the arrow axis used for this one."), myScript.dPad_X_axisName);
                myScript.dPad_Y_axisName = EditorGUILayout.TextField(new GUIContent("Joystick axis for the Y axis", "Name of the joystick input, the arrow axis used for this one."), myScript.dPad_Y_axisName);
                EditorGUILayout.EndVertical();
            }
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        EditorGUILayout.EndVertical();

        DrawDefaultInspector();
    }
    private void DrawSettings()
    {
        GUILayout.Space(10);

        // test for changes in exposed values
        EditorGUI.BeginChangeCheck();
        pupilTracker.SettingsTab = GUILayout.Toolbar(pupilTracker.SettingsTab, new string[] {
            "pupil app",
            "calibration",
            "recording"
        }, GUILayout.Height(30));
        ////////INPUT FIELDS////////
        switch (pupilTracker.SettingsTab)
        {
        case 0:        //PUPIL APP
            if (isCalibrating)
            {
                GUI.enabled = false;
            }

            GUILayout.Space(10);

            ////////////////////////////TOGGLE AUTO MODE////////////////////////////
            cInspector.isAutorunService = GUILayout.Toggle(cInspector.isAutorunService, "Autorun Pupil Service", "Button");
            if (!cInspector.isAutorunService && Application.isPlaying)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Start"))
                {
                    if (!isConnected)
                    {
                        pupilTracker.CreateAndRunServiceThread();
                        pupilTracker.RunServiceAtPath();
                    }
                    else
                    {
                        pupilTracker.StartProcess();
                    }
                }
                if (GUILayout.Button("Stop"))
                {
                    pupilTracker.StopProcess();
                }
                GUILayout.EndHorizontal();
            }
            ////////////////////////////TOGGLE AUTO MODE////////////////////////////

            GUILayout.Space(20);

            ////////////////////////////CONNECTION MODE////////////////////////////
            EditorGUI.BeginChangeCheck();
            //GUI.color = new Color (.7f, .7f, .7f, 1f);
            pupilTracker.customInspector.connectionMode = GUILayout.Toolbar(pupilTracker.customInspector.connectionMode, new string[] { "Local", "Remote" }, GUILayout.Height(30), GUILayout.MinWidth(25));
            GUI.color = Color.white;
            if (EditorGUI.EndChangeCheck())
            {
                if (pupilTracker.customInspector.connectionMode == 0)
                {
                    tempServerIP = pupilTracker.customInspector.ServerIP;
                    pupilTracker.customInspector.ServerIP = "127.0.0.1";
                }
                else
                {
                    pupilTracker.customInspector.ServerIP = tempServerIP;
                }
            }
            ////////////////////////////CONNECTION MODE////////////////////////////
            GUILayout.Space(5);
            if (pupilTracker.customInspector.connectionMode == 0)              //LOCAL CONNECTION MODE//
            ////////////////////////////PUPIL APP PATH////////////////////////////
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("path : ", pupilTracker.Styles [6], GUILayout.MinWidth(50));
                pupilTracker.PupilServicePath = EditorGUILayout.TextArea(pupilTracker.PupilServicePath, pupilTracker.Styles [7], GUILayout.MinWidth(100), GUILayout.Height(22));
                if (GUILayout.Button("Browse"))
                {
                    pupilTracker.PupilServicePath = EditorUtility.OpenFilePanel("Select Pupil service application file", pupilTracker.PupilServicePath, "exe");
                }
                GUILayout.EndHorizontal();
                ////////////////////////////PUPIL APP PATH////////////////////////////
            }

            if (cInspector.AdvancedSettings)             //ADVANCED SETTING

            ////////////////////////////SERVICE PORT////////////////////////////
            ///
            {
                GUILayout.BeginHorizontal();                 //---------HORIZONTAL GROUP---------//
                //
                GUILayout.Label("Service Port : ", pupilTracker.Styles[6], GUILayout.MinWidth(50));
                pupilTracker.ServicePort = EditorGUILayout.IntField(pupilTracker.ServicePort, pupilTracker.Styles[8], GUILayout.MinWidth(100), GUILayout.Height(22));
                //
                GUILayout.EndHorizontal();                 //---------HORIZONTAL GROUP\---------//
                ///
                ////////////////////////////SERVICE PORT\////////////////////////////
                base.OnInspectorGUI();
                GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); //Separator Line
            }                                                                        //ADVANCED SETTING\

            if (pupilTracker.customInspector.connectionMode == 1)                    //---------REMOTE CONNECTION MODE---------//



            {
                GUILayout.Space(5);

                ////////////////////////////SERVER IP ADDRESS////////////////////////////
                ///
                GUILayout.BeginHorizontal();                 //---------HORIZONTAL GROUP---------//
                //
                GUILayout.Label("IP : ", pupilTracker.Styles [6], GUILayout.MinWidth(50));
                //
                pupilTracker.customInspector.ServerIP = EditorGUILayout.TextArea(pupilTracker.customInspector.ServerIP, pupilTracker.Styles[8], GUILayout.MinWidth(50), GUILayout.Height(22));
                if (GUILayout.Button("Default"))
                {
                    pupilTracker.customInspector.ServerIP = "127.0.0.1";
                    Repaint();
                    GUI.FocusControl("");
                }
                //
                GUI.enabled = true;
                //
                GUILayout.EndHorizontal();                 //---------HORIZONTAL GROUP\---------//
                ///
                ////////////////////////////SERVER IP ADDRESS\////////////////////////////


                GUI.enabled = true;
            }            //---------REMOTE CONNECTION MODE\---------//


            break;

        case 1:        //CALIBRATION


            GUILayout.Space(20);

            ////////////////////////////2D-3D TOGGLE BAR////////////////////////////
            EditorGUI.BeginChangeCheck();
            cInspector.calibrationMode = GUILayout.Toolbar(cInspector.calibrationMode, new string[] { "2D", "3D" });
            GUI.enabled = true;
            if (EditorGUI.EndChangeCheck())
            {
                pupilTracker.SwitchCalibrationMode();
            }
            ////////////////////////////2D-3D TOGGLE BAR////////////////////////////

            ////////////////////////////CALIBRATION DEBUG MODE////////////////////////////
            if (isCalibrating || !isEyeProcessConnected || cInspector.calibrationMode != 1)
            {
            }
            else
            {
                //GUI.enabled = false;

                EditorGUI.BeginChangeCheck();
                cInspector.calibrationDebugMode = GUILayout.Toggle(cInspector.calibrationDebugMode, "Calibration Debug Mode", "Button");
                GUI.enabled = true;
                if (EditorGUI.EndChangeCheck())
                {
                    if (cInspector.calibrationDebugMode)
                    {
                        if (pupilTracker.OperatorMonitorProperties [0].OperatorCamera != null)
                        {
                            OperatorMonitor.Instance.ExitOperatorMonitor();
                        }
                        pupilTracker.StartCalibrationDebugView();
                    }
                    else
                    {
                        pupilTracker.CloseCalibrationDebugView();
                    }
                }
            }

            if (cInspector.calibrationDebugMode)
            {
                //				pupilTracker.calibrationDebugCamera = (PupilGazeTracker.CalibrationDebugCamera) EditorGUILayout.EnumPopup (pupilTracker.calibrationDebugCamera);
                GUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                pupilTracker.DebugViewVariables.isDrawLines  = GUILayout.Toggle(pupilTracker.DebugViewVariables.isDrawLines, " Draw Debug Lines ", "Button");
                pupilTracker.DebugViewVariables.isDrawPoints = GUILayout.Toggle(pupilTracker.DebugViewVariables.isDrawPoints, " Draw Debug Points ", "Button");
                if (EditorGUI.EndChangeCheck())
                {
                    pupilTracker.SetDrawCalibrationPointCloud(pupilTracker.DebugViewVariables.isDrawPoints);
                    pupilTracker.SetDrawCalibrationLines(pupilTracker.DebugViewVariables.isDrawLines);
                }
                GUILayout.EndHorizontal();
            }

            GUI.enabled = true;
            ////////////////////////////CALIBRATION DEBUG MODE////////////////////////////

            GUILayout.Space(20);

            GUILayout.BeginHorizontal();             ////////////////////HORIZONTAL////////////////////
            GUILayout.Label("Samples ", pupilTracker.Styles[6], GUILayout.MinWidth(35));
            pupilTracker.DefaultCalibrationCount = EditorGUILayout.IntSlider(pupilTracker.DefaultCalibrationCount, 1, 120, GUILayout.ExpandWidth(true));
            GUILayout.EndHorizontal();       ////////////////////HORIZONTAL////////////////////

            GUILayout.Space(10);             //------------------------------------------------------------//

            if (cInspector.AdvancedSettings)
            {
                base.OnInspectorGUI();
            }
            break;
        }


        //if change found set scene as dirty, so user will have to save changed values.
        if (EditorGUI.EndChangeCheck() && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }

        GUILayout.Space(10);
    }
        protected void DrawControls()
        {
            MBGraphNode target = (MBGraphNode)this.target;

            EditorGUILayout.Space();

            List <MBGraphNode> selectedNodes = new List <MBGraphNode>();

            foreach (GameObject obj in Selection.gameObjects)
            {
                if (obj.GetComponent <MBGraphNode>() != null)
                {
                    selectedNodes.Add(obj.GetComponent <MBGraphNode>());
                }
            }

            if (selectedNodes.Count == 1)
            {
                // A single node is selected
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    if (GUILayout.Button("Add Node"))
                    {
                        GameObject addedNode = null;
                        if (addNodeEdgeDirectionality == 2)
                        {
                            addedNode = target.mbGraph.AddNode();
                        }
                        else
                        {
                            addedNode = target.mbGraph.AddNode(target, addNodeEdgeWeight, (EdgeDirectionality)addNodeEdgeDirectionality);
                        }

                        Selection.activeGameObject = addedNode;
                    }

                    addNodeEdgeDirectionality   = EditorGUILayout.Popup("Edge Directionality", addNodeEdgeDirectionality, strEdgeDirectionalities);
                    addNodeEdgeWeightIsDistance = EditorGUILayout.Toggle("Weight == Distance", addNodeEdgeWeightIsDistance);
                    addNodeEdgeWeight           = EditorGUILayout.FloatField("Edge Weight", addNodeEdgeWeight);
                }
                EditorGUILayout.EndVertical();
            }
            else if (selectedNodes.Count == 2)
            {
                // A pair of nodes (edge) has been selected
                GraphEdge <float>[] modifiableEdges = new GraphEdge <float> [2];
                modifiableEdges[0] = target.mbGraph.graph.GetEdge(selectedNodes[0].nodeId, selectedNodes[1].nodeId);
                modifiableEdges[1] = target.mbGraph.graph.GetEdge(selectedNodes[1].nodeId, selectedNodes[0].nodeId);

                for (int i = 0; i < modifiableEdges.Length; ++i)
                {
                    GraphEdge <float> edge = modifiableEdges[i];

                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                    var edgeLabelStyle = new GUIStyle(GUI.skin.label)
                    {
                        fontStyle = FontStyle.Bold
                    };
                    EditorGUILayout.LabelField(i == 0 ? "A -> B" : "B -> A", edgeLabelStyle);
                    DrawHorizontalLine();

                    int   edgeDirectionalityInt = EditorGUILayout.Popup("Directionality", edge == null ? 2 : (int)edge.Directionality, strEdgeDirectionalities);
                    float edgeWeight            = EditorGUILayout.FloatField("Edge Weight", edge == null ? 0 : edge.Weight);
                    bool  edgeWeightIsDistance  = GUILayout.Button("Weight == Distance");

                    EditorGUILayout.EndVertical();

                    if (
                        (edge != null || edgeDirectionalityInt != 2) &&
                        ((edge == null && edgeDirectionalityInt != 2) || edgeWeight != edge.Weight || edgeDirectionalityInt != (int)edge.Directionality)
                        )
                    {
                        if (edge != null && edgeDirectionalityInt == 2)
                        {
                            target.mbGraph.RemoveEdge(edge.FromId, edge.ToId);
                        }
                        else if (edgeDirectionalityInt != 2)
                        {
                            if (i == 0)
                            {
                                target.mbGraph.SetEdge(selectedNodes[0], selectedNodes[1], edgeWeight, (EdgeDirectionality)edgeDirectionalityInt);
                            }
                            else if (i == 1)
                            {
                                target.mbGraph.SetEdge(selectedNodes[1], selectedNodes[0], edgeWeight, (EdgeDirectionality)edgeDirectionalityInt);
                            }
                        }

                        EditorSceneManager.MarkSceneDirty(target.gameObject.scene);
                        EditorUtility.SetDirty(target);
                    }

                    if (edgeWeightIsDistance)
                    {
                        target.mbGraph.graph.isDirty = true;
                        edge.Weight = (selectedNodes[0].transform.position - selectedNodes[1].transform.position).magnitude;
                        EditorSceneManager.MarkSceneDirty(target.gameObject.scene);
                        EditorUtility.SetDirty(target);
                    }

                    if (edgeDirectionalityInt == 0)
                    {
                        break;
                    }
                }
            }
        }
Пример #29
0
    private void DrawSettings()
    {
        // test for changes in exposed values
        EditorGUI.BeginChangeCheck();

        pupilTracker.SettingsTab = GUILayout.Toolbar(pupilTracker.SettingsTab, new string[] { "Service", "Calibration" });
        GUILayout.Space(30);
        ////////INPUT FIELDS////////
        switch (pupilTracker.SettingsTab)
        {
        case 0:                          //SERVICE
            GUILayout.BeginHorizontal(); ////////////////////HORIZONTAL////////////////////BROWSE FOR PUPIL SERVICE PATH
            GUILayout.Label("Pupil Service App Path : ", pupilTracker.SettingsLabelsStyle, GUILayout.Width(150));
            pupilTracker.PupilServicePath = EditorGUILayout.TextArea(pupilTracker.PupilServicePath, pupilTracker.SettingsBrowseStyle, GUILayout.Width(150), GUILayout.Height(22));
            if (GUILayout.Button("Browse", GUILayout.Width(55), GUILayout.Height(22)))
            {
                pupilTracker.PupilServicePath = EditorUtility.OpenFolderPanel("TITLE", pupilTracker.PupilServicePath, "Default Name !");
            }
            GUILayout.EndHorizontal();             ////////////////////HORIZONTAL////////////////////

            EditorGUILayout.Separator();           //------------------------------------------------------------//

            GUILayout.BeginHorizontal();           ////////////////////HORIZONTAL////////////////////
            GUILayout.Label("Server IP : ", pupilTracker.SettingsLabelsStyle, GUILayout.Width(150));
            pupilTracker.ServerIP = EditorGUILayout.TextArea(pupilTracker.ServerIP, pupilTracker.SettingsValuesStyle, GUILayout.Width(150), GUILayout.Height(22));
            GUILayout.EndHorizontal();             ////////////////////HORIZONTAL////////////////////

            EditorGUILayout.Separator();           //------------------------------------------------------------//

            GUILayout.BeginHorizontal();           ////////////////////HORIZONTAL////////////////////
            GUILayout.Label("Service Port : ", pupilTracker.SettingsLabelsStyle, GUILayout.Width(150));
            pupilTracker.ServicePort = EditorGUILayout.IntField(pupilTracker.ServicePort, pupilTracker.SettingsValuesStyle, GUILayout.Width(150), GUILayout.Height(22));
            GUILayout.EndHorizontal();      ////////////////////HORIZONTAL////////////////////

            GUILayout.Space(5);             //------------------------------------------------------------//

            GUILayout.BeginHorizontal();    ////////////////////HORIZONTAL////////////////////
            GUILayout.Label("Show All : ", pupilTracker.SettingsLabelsStyle, GUILayout.Width(150));
            pupilTracker.ShowBaseInspector = EditorGUILayout.Toggle(pupilTracker.ShowBaseInspector);
            GUILayout.EndHorizontal();             ////////////////////HORIZONTAL////////////////////

            break;

        case 1:                          //CALIBRATION

            GUILayout.BeginHorizontal(); ////////////////////HORIZONTAL////////////////////
            GUILayout.Label("GameObject for 3D calibration : ", pupilTracker.SettingsLabelsStyle, GUILayout.Width(200));
            pupilTracker.CalibrationGameObject3D = (GameObject)EditorGUILayout.ObjectField(pupilTracker.CalibrationGameObject3D, typeof(GameObject), true);
            GUILayout.EndHorizontal();      ////////////////////HORIZONTAL////////////////////

            GUILayout.Space(5);             //------------------------------------------------------------//

            GUILayout.BeginHorizontal();    ////////////////////HORIZONTAL////////////////////
            GUILayout.Label("GameObject for 2D calibration : ", pupilTracker.SettingsLabelsStyle, GUILayout.Width(200));
            pupilTracker.CalibrationGameObject2D = (GameObject)EditorGUILayout.ObjectField(pupilTracker.CalibrationGameObject2D, typeof(GameObject), true);
            GUILayout.EndHorizontal();             ////////////////////HORIZONTAL////////////////////

            GUILayout.BeginHorizontal();           ////////////////////HORIZONTAL////////////////////
            GUILayout.Label("Calibration Sample Count : ", pupilTracker.SettingsLabelsStyle, GUILayout.Width(175));
            pupilTracker.DefaultCalibrationCount = EditorGUILayout.IntSlider(pupilTracker.DefaultCalibrationCount, 1, 120);
            GUILayout.EndHorizontal();             ////////////////////HORIZONTAL////////////////////
            break;
        }

        /// Accessing the relevant GUIStyles from PupilGazeTracker

        ////////INPUT FIELDS////////

        //if change found set scene as dirty, so user will have to save changed values.
        if (EditorGUI.EndChangeCheck())
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }

        GUILayout.Space(50);
    }
Пример #30
0
        public override void OnInspectorGUI()
        {
            serializedObject.UpdateIfRequiredOrScript();

            GUI.enabled = cloth.Initialized;
            EditorGUI.BeginChangeCheck();
            editMode = GUILayout.Toggle(editMode, new GUIContent("Edit particles", Resources.Load <Texture2D>("EditParticles")), "LargeButton");
            if (EditorGUI.EndChangeCheck())
            {
                SceneView.RepaintAll();
            }
            GUI.enabled = true;

            EditorGUILayout.LabelField("Status: " + (cloth.Initialized ? "Initialized":"Not initialized"));

            GUI.enabled = (cloth.SharedTopology != null);
            if (GUILayout.Button("Initialize"))
            {
                if (!cloth.Initialized)
                {
                    EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                    CoroutineJob job = new CoroutineJob();
                    routine = job.Start(cloth.GeneratePhysicRepresentationForMesh());
                    EditorCoroutine.ShowCoroutineProgressBar("Generating physical representation...", ref routine);
                    EditorGUIUtility.ExitGUI();
                }
                else
                {
                    if (EditorUtility.DisplayDialog("Actor initialization", "Are you sure you want to re-initialize this actor?", "Ok", "Cancel"))
                    {
                        EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                        CoroutineJob job = new CoroutineJob();
                        routine = job.Start(cloth.GeneratePhysicRepresentationForMesh());
                        EditorCoroutine.ShowCoroutineProgressBar("Generating physical representation...", ref routine);
                        EditorGUIUtility.ExitGUI();
                    }
                }
            }
            GUI.enabled = true;

            if (cloth.SharedTopology == null)
            {
                EditorGUILayout.HelpBox("No ObiMeshTopology asset present.", MessageType.Info);
            }

            GUI.enabled = cloth.Initialized;
            if (GUILayout.Button("Set Rest State"))
            {
                Undo.RecordObject(cloth, "Set rest state");
                cloth.PullDataFromSolver(ParticleData.POSITIONS | ParticleData.VELOCITIES);
            }
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Optimize"))
            {
                Undo.RecordObject(cloth, "Optimize");
                cloth.Optimize();
            }
            if (GUILayout.Button("Unoptimize"))
            {
                Undo.RecordObject(cloth, "Unoptimize");
                cloth.Unoptimize();
            }
            GUILayout.EndHorizontal();

            GUI.enabled = true;

            Editor.DrawPropertiesExcluding(serializedObject, "m_Script");

            // Apply changes to the serializedProperty
            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
            }
        }