private void AfterDeserialize()
        {
            EditorApplication.update -= AfterDeserialize;

            // Asset has already been set, and will be used in editor instead of the path.
            if (sceneAssetIsSet)
            {
                return;
            }

            // Asset has not been set, so attempt to find the asset with the known path
            if (_scenePath != null && _scenePath != "")
            {
                sceneAsset = GetAssetFromPath();

                // If no scene asset found, reset the scene path to avoid using outdated paths.
                if (sceneAsset == null)
                {
                    _scenePath = "";
                }

                // Set scene name
                _sceneName = null;
                if (sceneAsset != null)
                {
                    string path = scenePath.Substring(scenePath.LastIndexOf('/') + 1);
                    _sceneName = path.Substring(0, path.LastIndexOf('.'));
                }

                if (Application.isPlaying == false)
                {
                    EditorSceneManager.MarkAllScenesDirty();
                }
            }
        }
    public static void ApplyToAllScrollRects()
    {
        GameObject[] targets = Selection.gameObjects;

        // Iterate over all selected game objects
        foreach (GameObject target in targets)
        {
            ScrollRect[] rects = target.GetComponentsInChildren <ScrollRect>(true);

            // Iterate over all scroll rects, setting up a script reset on each
            foreach (ScrollRect rect in rects)
            {
                ResetScrollOnEnable script = rect.GetComponent <ResetScrollOnEnable>();

                // If the script does not exist then add it
                if (!script)
                {
                    script = Undo.AddComponent <ResetScrollOnEnable>(rect.gameObject);
                }

                // Record changes to the script
                Undo.RecordObject(script, $"Reset Scroll View On Enable");
                script.SetScrollRect(rect);
            }
        }

        // Mark the scenes as dirty so changes can be saved
        EditorSceneManager.MarkAllScenesDirty();
    }
    public static void ApplyMaterials(Material mat)
    {
        ClearLists();

        foreach (GameObject go in Selection.gameObjects)
        {
            Transform[] allChildren = go.GetComponentsInChildren <Transform>();
            foreach (Transform child in allChildren)
            {
                Renderer r = child.gameObject.GetComponent <Renderer>();
                if (r == null)
                {
                    continue;
                }

                Gameobjects.Add(child.gameObject);

                Material m = r.sharedMaterial;
                Materials.Add(m);

                r.material = mat;
            }
        }

        // previousMat = go.GetComponent<Renderer>().sharedMaterial;
        //Undo.RecordObject(go,"Added Material:" + mat);
        // Undo.RegisterCompleteObjectUndo(go, "Added Material");
        //  go.GetComponent<Renderer>().material = mat;

        EditorSceneManager.MarkAllScenesDirty();
    }
    void OnGUI()
    {
        //Debug.Log(SceneManager.sceneCountInBuildSettings);
        int temp = 0;

        toggle = EditorGUILayout.Toggle("Save before loading", toggle);
        if (pain == null || pain.Count < SceneManager.sceneCountInBuildSettings || pain.Count > SceneManager.sceneCountInBuildSettings || safeCounter > 30)
        {
            PainInit(); safeCounter = 0;
        }

        for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
        {
            if (GUILayout.Button(suffering[i]))
            {
                if (toggle)
                {
                    EditorSceneManager.MarkAllScenesDirty();
                    EditorSceneManager.SaveOpenScenes();
                }

                EditorSceneManager.OpenScene(pain[temp]);
            }
            temp++;
        }

        safeCounter++;
    }
    public static void pasteCustomBrush(Vector3 position)
    {
        if (YuME_mapEditor.brushTile != null)
        {
            if (YuME_mapEditor.findTileMapParent())
            {
                Undo.RegisterFullObjectHierarchyUndo(YuME_mapEditor.tileMapParent, "Paint Custom Brush");

                foreach (Transform child in YuME_mapEditor.brushTile.transform)
                {
                    GameObject pasteTile = PrefabUtility.InstantiatePrefab(getPrefabFromCurrentTiles(child.gameObject) as GameObject) as GameObject;
                    if (pasteTile != null)
                    {
                        child.position = normalizePosition(child.position);
                        YuME_tileFunctions.eraseTile(child.position);
                        pasteTile.transform.eulerAngles = child.eulerAngles;
                        pasteTile.transform.position    = child.position;
                        pasteTile.transform.localScale  = child.transform.lossyScale;
                        pasteTile.transform.parent      = YuME_mapEditor.mapLayers[YuME_mapEditor.currentLayer - 1].transform;
                    }
                }

                EditorSceneManager.MarkAllScenesDirty();
            }
        }
    }
    public override void OnInspectorGUI()
    {
        ButterfliesArea area = (ButterfliesArea)target;

        EditorGUI.BeginChangeCheck();
        area.Count = EditorGUILayout.IntField("Count", area.Count);
        SerializedProperty prop  = serializedObject.FindProperty("prefabs");
        SerializedProperty speed = serializedObject.FindProperty("speed");

        EditorGUILayout.PropertyField(prop, true);
        EditorGUILayout.PropertyField(speed, true);
        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
            Undo.RecordObject(target, "Changed field");
        }
        EditorUtility.SetDirty(target);
        if (GUILayout.Button("Spawn"))
        {
            area.SpawnButterflies();
        }
        if (GUILayout.Button("Remove all"))
        {
            area.RemoveButterflies();
        }
        if (!Application.isPlaying)
        {
            EditorSceneManager.MarkAllScenesDirty();
        }
    }
    void SchemeByTag(string newTag, string scheme)
    {
        foreach (string customColorSettingsName in CustomColorSettingsNames)
        {
            if (customColorSettingsName == scheme)
            {
                Debug.LogWarning("Please use an different scheme name.");
                return;
            }
        }
        if (string.IsNullOrEmpty(newTag))
        {
            Debug.LogWarning("Please assign an valid tag.");
            return;
        }
        if (string.IsNullOrEmpty(scheme))
        {
            Debug.LogWarning("Please assign an valid scheme name.");
            return;
        }
        UIColorScheme colorScheme = new UIColorScheme(scheme, Color.gray, Color.gray, 2, newTag);

        CustomColorSchemes.Add(colorScheme);
        CustomColorSettingsNames.Add(scheme);
        SceneView.RepaintAll();
        EditorSceneManager.MarkAllScenesDirty();


        GUILayout.EndHorizontal();
    }
    //=================================================================================
    //反映
    //=================================================================================

    //PersistentAmongPlayModeの属性が付いた値を反映
    private static void ApplyValue(MonoBehaviour component)
    {
        //終了ボタンを押した時に存在しなかった(シーン再生中に削除されたとかで)やつはスルー
        if (!_valueDictDict.ContainsKey(component.GetInstanceID()))
        {
            return;
        }

        //各フィールドの値を保存したDictを取得
        var valueDict = _valueDictDict[component.GetInstanceID()];

        //PersistentAmongPlayModeの属性が付いた値だけ反映
        var isChangedValue = false; //値に変更があったか

        ExecuteProcessToAllPersistentAmongPlayModeField(component, fieldInfo => {
            var fieldName = fieldInfo.Name;

            //値が変化したかを判定(値の変更を直接比較するとうまく行かないのでStringにして比較)
            isChangedValue = isChangedValue || fieldInfo.GetValue(component).ToString() != valueDict[fieldName].ToString();

            //値の反映
            fieldInfo.SetValue(component, valueDict[fieldName]);
        });

        //値の変更があったら保存出来るようにするため、シーンに変更があったこと(米印)を設定
        if (isChangedValue)
        {
            EditorSceneManager.MarkAllScenesDirty();
        }
    }
Exemple #9
0
        public void OnSceneGUI()
        {
            if (targetScript == null)
            {
                OnEnable();
            }

            EditorGUI.BeginChangeCheck();

            Handles.color = Color.blue;


            if (usePerHandSettings.boolValue)
            {
                float rightValue = Handles.RadiusHandle(Quaternion.identity, targetScript.HighlightPointRightHand == null ? targetScript.transform.position : targetScript.HighlightPointRightHand.position, grabDistance.floatValue);
                float leftValue  = Handles.RadiusHandle(Quaternion.identity, targetScript.HighlightPointLeftHand == null ? targetScript.transform.position : targetScript.HighlightPointLeftHand.position, grabDistance.floatValue);

                UpdateGrabDistanceValue(rightValue, leftValue);
            }
            else
            {
                if (targetScript.HighlightPointHandSettings == null)
                {
                    return;
                }

                float value = Handles.RadiusHandle(Quaternion.identity, targetScript.HighlightPointHandSettings.position, grabDistance.floatValue);
                targetScript.SetInteractDistanceViaInspector(value);
                EditorUtility.SetDirty(targetScript);
                EditorSceneManager.MarkAllScenesDirty();
            }
        }
Exemple #10
0
        public void Execute(ICommand command)
        {
            if (_inUndoRedo)
            {
                throw new InvalidOperationException("An undo/redo operation is in progress.");
            }

            _redoStack.Clear();
            command.Execute();
            EditorSceneManager.MarkAllScenesDirty();

            if (_tracker != null)
            {
                // when Unity calls UnityEditor.Undo.PerformUndo() the tracker index will
                // automatically revert back to the value set here
                _tracker.Index = _undoStack.Count;
                UnityEditor.Undo.RecordObject(_tracker, command.Name);
            }

            _undoStack.Push(command);

            if (_tracker != null)
            {
                // when Unity calls UnityEditor.Undo.PerformRedo() the tracker index will
                // automatically revert back to the value set here
                _tracker.Index = _undoStack.Count;
                Debug.Log("RecordObject Group ID: " + UnityEditor.Undo.GetCurrentGroup());
            }
        }
        /// <summary>
        /// Undo를 위해 Action을 저장한다.
        /// Label과 기록되는 값을 통해서 중복 여부를 체크한다.
        /// </summary>
        /// <param name="parentObject">변동되는 오브젝트의 Parent</param>
        /// <param name="targetObject">변동되는 오브젝트</param>
        /// <param name="isMultiple">한번에 여러개의 객체를 동시에 처리하는가</param>
        public static void SetRecord(apUndoGroupData.ACTION action,
                                     MonoBehaviour parentMonoObject,                                            //<<이게 중요
                                     object targetObject,
                                     bool isMultiple,
                                     apEditor editor)
        {
            if (editor._portrait == null)
            {
                return;
            }
            //연속된 기록이면 Undo/Redo시 한번에 묶어서 실행되어야 한다. (예: 버텍스의 실시간 이동 기록)
            //이전에 요청되었던 기록이면 Undo ID를 유지해야한다.
            bool isNewAction = apUndoGroupData.I.SetAction(action, parentMonoObject, targetObject, isMultiple);


            EditorSceneManager.MarkAllScenesDirty();

            //새로운 변동 사항이라면 UndoID 증가
            if (isNewAction)
            {
                Undo.IncrementCurrentGroup();
                _lastUndoID = Undo.GetCurrentGroup();
            }

            Undo.RecordObject(parentMonoObject, apUndoGroupData.GetLabel(action));            //MonoObject별로 다르게 Undo를 등록하자

            if (targetObject != null && targetObject != parentMonoObject as object && targetObject is MonoBehaviour)
            {
                //타겟 오브젝트도 Monobehaviour라면 같이 저장
                Undo.RecordObject(targetObject as MonoBehaviour, apUndoGroupData.GetLabel(action));
            }

            //테스트를 위해서 Undo 기록이 발생하면 노티를 띄운다. (Undo ID를 같이)
            //editor.Notification("U:" + apUndoGroupData.GetLabel(action) + " - " + Undo.GetCurrentGroup(), true);
        }
    public override void OnInspectorGUI()
    {
        if (m_ui == null)
        {
            m_ui = (UIWindowBase)target;
        }
        if (canvas == null)
        {
            canvas = m_ui.gameObject.GetComponent <Canvas>();
        }

        list        = UIManager.GetCameraNames();
        selectIndex = GetIndex(m_ui.cameraKey);

        selectIndex = EditorGUILayout.Popup("Camera Key", selectIndex, list);
        if (list.Length != 0)
        {
            m_ui.cameraKey = list[selectIndex];
        }

        base.OnInspectorGUI();
        if (!Application.isPlaying && GUI.changed)
        {
            EditorUtility.SetDirty(target);
            EditorSceneManager.MarkAllScenesDirty();
            canvas.sortingLayerName = m_ui.m_UIType.ToString();
        }
    }
Exemple #13
0
    public static void LogLightingSpriteData()
    {
        for (int i = 0; i < EditorSceneManager.loadedSceneCount; i++)
        {
            Scene scene = EditorSceneManager.GetSceneAt(i);
            foreach (var root in scene.GetRootGameObjects())
            {
                foreach (var node in TraverseTransformTree(root.transform))
                {
                    GameObject        gameObject = node.gameObject;
                    StaticEditorFlags flags      = GameObjectUtility.GetStaticEditorFlags(gameObject);
                    if ((flags & StaticEditorFlags.LightmapStatic) == 0)
                    {
                        continue;
                    }

                    SpriteRenderer spriteRenderer = node.GetComponent <SpriteRenderer>();
                    if (!spriteRenderer)
                    {
                        continue;
                    }

                    Debug.Log(string.Format("Lightmap .Index = {0}; .ScaleOffset = {1}", spriteRenderer.lightmapIndex, spriteRenderer.lightmapScaleOffset));
                }
            }
        }

        EditorSceneManager.MarkAllScenesDirty();
    }
Exemple #14
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            var player = target as Tower.Player;

            if (player != null)
            {
                GUILayout.Space(3);
                GUILayout.Label("Attributes:");
                if (Tower.Editor.Utility.AttributesField(player.Attrs))
                {
                    if (!Application.isPlaying)
                    {
                        EditorUtility.SetDirty(player); // this line doesn't work at unity5
                        EditorSceneManager.MarkAllScenesDirty();
                    }
                }

                GUILayout.Space(3);
                GUILayout.Label("Switches:");
                if (Tower.Editor.Utility.SwitchField(player.Switches))
                {
                    if (!Application.isPlaying)
                    {
                        EditorUtility.SetDirty(player); // this line doesn't work at unity5
                        EditorSceneManager.MarkAllScenesDirty();
                    }
                }
            }
        }
Exemple #15
0
        private void OnGUI()
        {
            if (_currentAction != null)
            {
                if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return)
                {
                    if (!Application.isPlaying)
                    {
                        EditorSceneManager.MarkAllScenesDirty();
                    }
                    //Close();
                    Repaint();
                }

                _currentAction.DrawEditorGui();

                GUIStyle savBt = new GUIStyle(GUI.skin.button)
                {
                    //normal = { background = _currentAction._changed ? EventAction.MakeTexSq("ff0000") : EventAction.MakeTexSq("666666") },
                    name = "Save"
                };

                if (!Application.isPlaying && GUILayout.Button("Save", savBt))
                {
                    EditorSceneManager.MarkAllScenesDirty();
                    //_currentAction._changed = false;
                }
            }
            else
            {
                GUILayout.Label("Select action");
            }
        }
Exemple #16
0
        private void AssignSelf()
        {
            if (GUILayout.Button("Assign", EditorStyles.miniButton))
            {
                List <GameObject> rootObjects = new List <GameObject>();
                int sceneCount = EditorSceneManager.sceneCount;

                for (int i = 0; i < sceneCount; i++)
                {
                    EditorSceneManager.GetSceneAt(i).GetRootGameObjects(rootObjects);
                    foreach (GameObject rootObject in rootObjects)
                    {
                        foreach (MonoBehaviour behaviour in rootObject.GetComponentsInChildren <MonoBehaviour>(true))
                        {
                            foreach (FieldInfo variable in behaviour.GetType().GetFields())
                            {
                                if (variable.FieldType.IsInstanceOfType(_target))
                                {
                                    variable.SetValue(behaviour, _target);
                                }
                            }
                        }
                    }
                }

                EditorSceneManager.MarkAllScenesDirty();
                EditorUtility.SetDirty(_target);
            }
        }
Exemple #17
0
    private void ReplacingObjects()
    {
        foreach (Transform item in transforms)
        {
            GameObject go;
            PrefabType pref = PrefabUtility.GetPrefabType(replacement);

            if (pref == PrefabType.Prefab || pref == PrefabType.ModelPrefab)
            {
                go = (GameObject)PrefabUtility.InstantiatePrefab(replacement);
            }
            else
            {
                go = (GameObject)Editor.Instantiate(replacement);
            }

            go.name                    = replacement.name;
            go.transform.parent        = item.transform;
            go.transform.localPosition = Vector3.zero;
            go.transform.localScale    = Vector3.one;
            go.transform.localRotation = Quaternion.identity;
            go.transform.parent        = item.parent;

            if (++counter < numberOfObjects)
            {
                EditorUtility.DisplayProgressBar("Replacing object...", string.Format("{0}/{1}", ++counter, numberOfObjects), (++counter / numberOfObjects));
            }
            else
            {
                EditorUtility.ClearProgressBar();
            }
        }

        EditorSceneManager.MarkAllScenesDirty();
    }
    public void LoadScene(string ID, string sceneTagName, bool editMode, bool doQueue)
    {
        if (editMode)
        {
            if (!tempDictionary.ContainsKey(sceneTagName))
            {
                var scene = EditorSceneManager.OpenScene(Application.dataPath + "/" + ID + "/SubScenes/" + sceneTagName + "_SubScene" + ".unity", OpenSceneMode.Additive);
                if (!tempDictionary.ContainsKey(sceneTagName))
                {
                    tempDictionary.Add(sceneTagName, scene);
                }
                EditorSceneManager.MarkAllScenesDirty();
            }
        }
        else
        {
            if (!tempDictionary.ContainsKey(sceneTagName))
            {
                Scene s     = SceneManager.GetSceneByName(sceneTagName + "_SubScene");
                var   scene = SceneManager.LoadSceneAsync(sceneTagName + "_SubScene", LoadSceneMode.Additive);

                scene.completed += LoadedScene;

                temps.Add((sceneTagName, doQueue));
            }
        }

        //Call PreAWake(); on all components of type SceneMonoBehaviour
    }
Exemple #19
0
        private void HandleAfterDeserialize()
        {
            // ReSharper disable once DelegateSubtraction
            EditorApplication.update -= HandleAfterDeserialize;
            // Asset is valid, don't do anything - Path will always be set based on it when it matters
            if (IsValidSceneAsset)
            {
                return;
            }

            // Asset is invalid but have path to try and recover from
            if (string.IsNullOrEmpty(scenePath))
            {
                return;
            }

            sceneAsset = GetSceneAssetFromPath();
            // No asset found, path was invalid. Make sure we don't carry over the old invalid path
            if (!sceneAsset)
            {
                scenePath = string.Empty;
            }

            if (!Application.isPlaying)
            {
                EditorSceneManager.MarkAllScenesDirty();
            }
        }
        // -------------------------------------------------------------------
        // Public
        // -------------------------------------------------------------------
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            EditorGUILayout.Space();

            if (GUILayout.Button("Apply Theme"))
            {
                UITheme theme = this.target as UITheme;

                if (theme != null)
                {
                    if (UIThemeSystem.IsInstanceActive)
                    {
                        UIThemeSystem.Instance.SetTheme(theme);
                    }
                    else
                    {
                        UIThemeSystem system = FindObjectOfType <UIThemeSystem>();
                        if (system != null)
                        {
                            system.SetTheme(theme);
                        }
                    }

                    UIThemeSystem.Instance.ApplyTheme();

                    if (!Application.isPlaying)
                    {
                        EditorSceneManager.MarkAllScenesDirty();
                    }
                }
            }
        }
    public static void PrepareSprites()
    {
        for (int i = 0; i < EditorSceneManager.loadedSceneCount; i++)
        {
            Scene scene = EditorSceneManager.GetSceneAt(i);
            foreach (var root in scene.GetRootGameObjects())
            {
                foreach (var node in TraverseTransformTree(root.transform))
                {
                    GameObject        gameObject = node.gameObject;
                    StaticEditorFlags flags      = GameObjectUtility.GetStaticEditorFlags(gameObject);
                    if ((flags & StaticEditorFlags.LightmapStatic) == 0)
                    {
                        continue;
                    }

                    SpriteRenderer spriteRenderer = node.GetComponent <SpriteRenderer>();
                    if (!spriteRenderer)
                    {
                        continue;
                    }

                    // Create if not find a BakedLigthingSpriteData
                    BakedLigthingSpriteData data = gameObject.GetComponent <BakedLigthingSpriteData>();
                    if (!data)
                    {
                        data = gameObject.AddComponent <BakedLigthingSpriteData>();
                    }
                    data.BuildMesh();
                }
            }
        }

        EditorSceneManager.MarkAllScenesDirty();
    }
        public void Run()
        {
            // 遍历文件
            if (!Directory.Exists(mPathExcel))
            {
                Directory.CreateDirectory(mPathExcel);
            }
            var files = (new DirectoryInfo(mPathExcel)).GetFiles();

            for (int i = 0; i < files.Length; ++i)
            {
                if (files[i].Extension == ".xlsx" && !IsChinese(files[i].Name) && IsCorrectXLSX(files[i].Name))
                {
                    mProgress = (i + 0.1f) / files.Length;
                    try
                    {
                        Export(files[i]);
                    }
                    catch (Exception exp)
                    {
                        Debug.LogError(string.Format("[{0}]: {1}", files[i].Name, exp.Message));
                    }
                }
            }
            ClearInvalidFile();
            EditorUtility.ClearProgressBar();
            EditorSceneManager.MarkAllScenesDirty();
        }
Exemple #23
0
    public static void ToggleHideAutoSaveComponents()
    {
        bool hide = !AutoSaveComponentsAreHidden();

        EditorPrefs.SetBool("HideAutoSaveComponents", hide);
        HideFlags goHideFlags        = hide ? HideFlags.HideInHierarchy : HideFlags.None;
        HideFlags componentHideFlags = hide ? HideFlags.HideInInspector : HideFlags.None;

        // Hide scene components.
        if (mgr != null)
        {
            mgr.gameObject.hideFlags = goHideFlags;
            EditorSceneManager.MarkAllScenesDirty();

            foreach (ES2AutoSave autoSave in mgr.sceneObjects)
            {
                autoSave.hideFlags = componentHideFlags;
            }
        }

        // Hide Prefab components.
        List <GameObject> prefabs = GetPrefabs();

        for (int i = 0; i < prefabs.Count; i++)
        {
            ES2AutoSave autoSave = prefabs[i].GetComponent <ES2AutoSave>();
            if (autoSave != null)
            {
                autoSave.hideFlags = componentHideFlags;
            }
        }
    }
    public static void WindowsBuildAndRun()
    {
        // Save any changes made to the Scene before Building
        EditorSceneManager.MarkAllScenesDirty();
        EditorSceneManager.SaveOpenScenes();

        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();

        buildPlayerOptions.scenes           = FindActiveScenesInBuildSettings();
        buildPlayerOptions.locationPathName = @"Build\Windows\" + Application.productName + ".exe";
        buildPlayerOptions.target           = BuildTarget.StandaloneWindows64;

        BuildReport  report  = BuildPipeline.BuildPlayer(buildPlayerOptions);
        BuildSummary summary = report.summary;

        if (summary.result == BuildResult.Succeeded)
        {
            UnityEngine.Debug.Log("Build succeeded!");
            // *** Option to launch Playmode in the Unity Editor after a successful build
            //EditorApplication.ExecuteMenuItem("Edit/Play");

            Process.Start(@"Build\Windows\" + Application.productName + ".exe");
            // *** FOR MULTIPLAYER TESTING *** Uncomment these lines if you need to test a multiplayer game
            //RunMultipleInstances();
        }

        if (summary.result == BuildResult.Failed)
        {
            UnityEngine.Debug.Log("*** WINDOWS BUILD FAILED! ***");
        }
    }
    public static void pasteCopyBrush(Vector3 position)
    {
        if (YuME_mapEditor.brushTile != null)
        {
            if (YuME_mapEditor.findTileMapParent())
            {
                Undo.RegisterFullObjectHierarchyUndo(YuME_mapEditor.tileMapParent, "Paint Brush");

                foreach (Transform child in YuME_mapEditor.brushTile.transform)
                {
#if UNITY_2018_3_OR_NEWER
                    GameObject pasteTile = (GameObject)PrefabUtility.InstantiatePrefab(PrefabUtility.GetCorrespondingObjectFromSource(child.gameObject) as GameObject);
#else
                    GameObject pasteTile = (GameObject)PrefabUtility.InstantiatePrefab(PrefabUtility.GetPrefabParent(child.gameObject) as GameObject);
#endif
                    YuME_tileFunctions.eraseTile(child.position);
                    pasteTile.transform.eulerAngles = child.eulerAngles;
                    pasteTile.transform.position    = normalizePosition(child.position);
                    pasteTile.transform.localScale  = child.transform.lossyScale;
                    pasteTile.transform.parent      = YuME_mapEditor.mapLayers[YuME_mapEditor.currentLayer - 1].transform;
                }

                EditorSceneManager.MarkAllScenesDirty();
            }
        }
    }
Exemple #26
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        // we only add a button and maybe some help labels, the rest can be default
        DrawDefaultInspector();

        var locationContainer = target as ArticyLocation;
        var targetGameObject  = locationContainer.gameObject;
        var mdl = locationContainer.location.GetObject() as ILocation;

        // without an actual articy location we can't create anything
        if (mdl == null)
        {
            EditorGUILayout.HelpBox("Selected object is not a valid location", MessageType.Warning, true);
        }

        UnityEngine.GUI.enabled = mdl != null;

        if (GUILayout.Button("Generate/Update location game objects"))
        {
            // this is a bit brute force, and will clear all children underneath our current game object
            // the user should make sure not to place anything important in it, because it will get overwritten
            targetGameObject.transform.Clear();
            // start the process
            ArticyLocationGenerator.GenerateLocation(targetGameObject, mdl, locationContainer.pixelsToUnits);
            // make sure a save will catch that
            EditorUtility.SetDirty(targetGameObject);
            EditorSceneManager.MarkAllScenesDirty();
        }
        UnityEngine.GUI.enabled = true;

        serializedObject.ApplyModifiedProperties();
    }
        static void UpdateSyncModes(List <UdonBehaviour> udonBehaviours)
        {
            int modificationCount = 0;

            foreach (UdonBehaviour behaviour in udonBehaviours)
            {
                if (behaviour.programSource == null || !(behaviour.programSource is UdonSharpProgramAsset programAsset))
                {
                    continue;
                }

                if (behaviour.Reliable == true &&
                    programAsset.behaviourSyncMode == BehaviourSyncMode.Continuous)
                {
                    behaviour.Reliable = false;
                    modificationCount++;
                }
                else if (behaviour.Reliable == false &&
                         programAsset.behaviourSyncMode == BehaviourSyncMode.Manual)
                {
                    behaviour.Reliable = true;
                    modificationCount++;
                }
            }

            if (modificationCount > 0)
            {
                EditorSceneManager.MarkAllScenesDirty();
            }
        }
Exemple #28
0
        bool UpdatePivot()
        {
            if (_transform)
            {
                bool updated = _transform.Freeze(_pivot, _transform.localRotation, _transform.localScale,
                                                 SaveMeshToFbxFolder);

                if (updated)
                {
                    _pivot = _transform.position;

                    _lastGizmoPivot = _pivot;

                    SelectMesh();

                    EditorSceneManager.MarkAllScenesDirty();
                }

                return(updated);
            }
            else
            {
                return(false);
            }
        }
Exemple #29
0
        private void OnGUI()
        {
            if (_currentAction != null)
            {
                if (Event.current.type == EventType.keyDown && Event.current.keyCode == KeyCode.Return)
                {
                    if (!Application.isPlaying)
                    {
                        EditorSceneManager.MarkAllScenesDirty();
                    }
                    Close();
                }

                _currentAction.DrawEditorGui();

                if (!Application.isPlaying && GUILayout.Button("Save"))
                {
                    EditorSceneManager.MarkAllScenesDirty();
                }
            }
            else
            {
                GUILayout.Label("Select action");
            }
        }
        private void BeforeSerialize()
        {
            // Asset has not been set, but path is known. Get asset with the path.
            if (!sceneAssetIsSet && _scenePath != null && _scenePath != "")
            {
                sceneAsset = GetAssetFromPath();
                if (sceneAsset == null)
                {
                    _scenePath = "";
                }

                // Set scene name
                _sceneName = null;
                if (sceneAsset != null)
                {
                    string path = scenePath.Substring(scenePath.LastIndexOf('/') + 1);
                    _sceneName = path.Substring(0, path.LastIndexOf('.'));
                }

                EditorSceneManager.MarkAllScenesDirty();
            }
            else
            {
                // If asset has been set, just use that.
                _scenePath = GetPathFromAsset();
            }
        }