private void Awake()
        {
            RuntimeTools.SpawnPrefabChanged   += OnSpawnPrefabChanged;
            RuntimeSelection.SelectionChanged += OnSelectionChanged;

            m_editor = RuntimeEditor.Instance;
        }
        private void Start()
        {
            m_parentPopup = GetComponentInParent <PopupWindow>();
            m_parentPopup.OK.AddListener(OnOK);

            RuntimeEditor     runtimeEditor = FindObjectOfType <RuntimeEditor>();
            ProjectFolderView resources     = runtimeEditor.GetComponentInChildren <ProjectFolderView>(true);
            IProjectManager   manager       = Dependencies.ProjectManager;

            if (manager != null)
            {
                ProjectItem[] itemsOfType = manager.Project.FlattenHierarchy();
                itemsOfType = itemsOfType.Where(item => item.TypeName != null && Type.GetType(item.TypeName) != null && ObjectType.IsAssignableFrom(Type.GetType(item.TypeName))).ToArray();

                m_resources = Instantiate(resources);
                // m_resources.TypeFilter = ObjectType;
                m_resources.transform.position = Vector3.zero;
                m_resources.transform.SetParent(ObjectsPanel, false);

                //manager.GetOrCreateObjects(itemsOfType, objects =>
                //{
                //    m_resources.SetObjects(objects, true);
                //});


                //m_resources.DoubleClick += OnResourcesDoubleClick;
                //m_resources.SelectionChanged += OnResourcesSelectionChanged;
                //m_resources.TypeFilter = ObjectType;
            }
        }
Ejemplo n.º 3
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            RuntimeEditor rtEditor = (RuntimeEditor)target;

            EditorGUI.BeginChangeCheck();
            //bool isOn = EditorGUILayout.Toggle("IsOn", rtEditor.IsOn);
            //if (EditorGUI.EndChangeCheck())
            //{
            //    Undo.RecordObject(rtEditor, "Battlehub.RTEditor.IsOn");
            //    EditorUtility.SetDirty(rtEditor);
            //    rtEditor.IsOn = isOn;
            //}

            EditorGUI.BeginChangeCheck();
            int layer = EditorGUILayout.LayerField("RaycastLayer", rtEditor.RaycastLayer);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(rtEditor, "Battlehub.RTEditor.RaycastLayer");
                EditorUtility.SetDirty(rtEditor);
                rtEditor.RaycastLayer = layer;
            }
        }
Ejemplo n.º 4
0
        private void Awake()
        {
            if (m_instance != null)
            {
                Debug.LogWarning("Another instance of RuntimeEditor exists");
            }
            m_instance = this;

            m_projectManager = Dependencies.ProjectManager;
            if (m_projectManager == null)
            {
                Debug.LogWarning("ProjectManager not found");
            }

            if (m_projectManager != null)
            {
                m_projectManager.IgnoreTypes(
                    typeof(SpriteGizmo),
                    typeof(AudioReverbZoneGizmo),
                    typeof(AudioSourceGizmo),
                    typeof(BoxColliderGizmo),
                    typeof(CapsuleColliderGizmo),
                    typeof(SphereColliderGizmo),
                    typeof(LightGizmo),
                    typeof(DirectionalLightGizmo),
                    typeof(PointLightGizmo),
                    typeof(SpotlightGizmo),
                    typeof(SkinnedMeshRendererGizmo));

                m_projectManager.SceneLoaded  += OnSceneLoaded;
                m_projectManager.SceneCreated += OnSceneCreated;
            }

            RuntimeEditorApplication.IsOpenedChanged       += OnIsOpenedChanged;
            RuntimeEditorApplication.PlaymodeStateChanging += OnPlaymodeStateChanging;

            ExposeToEditor[] editorObjects = ExposeToEditor.FindAll(ExposeToEditorObjectType.Undefined, false).Select(go => go.GetComponent <ExposeToEditor>()).ToArray();
            for (int i = 0; i < editorObjects.Length; ++i)
            {
                editorObjects[i].ObjectType = ExposeToEditorObjectType.EditorMode;
                editorObjects[i].Init();
            }

            ExposeToEditor.Awaked  += OnObjectAwaked;
            ExposeToEditor.Started += OnObjectStarted;
            RuntimeEditorApplication.SceneCameras = SceneCameras;

            PrepareCameras();
            RuntimeEditorApplication.SceneCameras[0].gameObject.SetActive(true);
            for (int i = 1; i < RuntimeEditorApplication.SceneCameras.Length; ++i)
            {
                RuntimeEditorApplication.SceneCameras[i].gameObject.SetActive(false);
            }

            EditorsMap.LoadMap();
        }
Ejemplo n.º 5
0
        private void OnDestroy()
        {
            if (m_instance == this)
            {
                m_instance = null;
                RuntimeEditorApplication.Reset();
                EditorsMap.Reset();
            }

            Unsubscribe();
        }
Ejemplo n.º 6
0
        private void Awake()
        {
            ExposeToEditor.Started += OnObjectStarted;

            if (m_instance != null)
            {
                Debug.LogWarning("Another instance of RuntimeEditor exists");
            }
            m_instance = this;

            if (SceneCamera == null)
            {
                SceneCamera = Camera.main;
            }

            SceneView.Camera = SceneCamera;
        }
        private void OnSpawnPrefabChanged(GameObject oldPrefab)
        {
            m_editor = RuntimeEditor.Instance;
            if (m_editor == null)
            {
                if (RuntimeTools.SpawnPrefab != null)
                {
                    RuntimeTools.SpawnPrefab = null;
                    Debug.LogError("Editor.Instance is null");
                }
                return;
            }

            if (m_resource == null)
            {
                return;
            }

            if (RuntimeTools.SpawnPrefab == m_resource)
            {
                m_state     = State.BeforeSpawn;
                enabled     = true;
                m_selection = RuntimeSelection.objects;
            }
            else
            {
                if (RuntimeTools.SpawnPrefab == null)
                {
                    if (oldPrefab == m_resource)
                    {
                        enabled     = false;
                        m_state     = State.Idle;
                        m_instance  = null;
                        m_selection = null;
                    }
                }
            }
        }
Ejemplo n.º 8
0
        private static void HideFromEditor()
        {
            RuntimeEditor     editor = Object.FindObjectOfType <RuntimeEditor>();
            List <GameObject> prefabs;

            if (editor != null)
            {
                Undo.RecordObject(editor, "Battlehub.RTEditor.ExposeToEditor");
                prefabs = new List <GameObject>(editor.Prefabs);
            }
            else
            {
                prefabs = new List <GameObject>();
            }

            foreach (GameObject go in Selection.gameObjects)
            {
                if (RuntimePrefabs.IsPrefab(go.transform))
                {
                    prefabs.Remove(go);
                }
                else
                {
                    ExposeToEditor exposeToEditor = go.GetComponent <ExposeToEditor>();
                    if (exposeToEditor != null)
                    {
                        Undo.DestroyObjectImmediate(exposeToEditor);
                    }
                }
            }

            if (editor != null)
            {
                editor.Prefabs = prefabs.ToArray();
            }

            EditorUtility.SetDirty(editor);
        }
Ejemplo n.º 9
0
        private static void ExposeToEditor()
        {
            RuntimeEditor editor = Object.FindObjectOfType <RuntimeEditor>();

            Undo.RecordObject(editor, "Battlehub.RTEditor.ExposeToEditor");
            List <GameObject> prefabs = new List <GameObject>(editor.Prefabs);

            foreach (GameObject go in Selection.gameObjects)
            {
                if (RuntimePrefabs.IsPrefab(go.transform))
                {
                    prefabs.Add(go);
                }
                else
                {
                    Undo.RegisterCreatedObjectUndo(go.AddComponent <ExposeToEditor>(), "Battlehub.RTEditor.ExposeToEditor");
                }
            }

            editor.Prefabs = prefabs.ToArray();

            EditorUtility.SetDirty(editor);
        }