protected override void Awake() { base.Awake(); IOC.Register <IRTE>(this); IOC.RegisterFallback(this); ExposeToEditor[] editorObjects = ExposeToEditor.FindAll(this, ExposeToEditorObjectType.Undefined, false).Select(go => go.GetComponent <ExposeToEditor>()).ToArray(); for (int i = 0; i < editorObjects.Length; ++i) { editorObjects[i].ObjectType = ExposeToEditorObjectType.EditorMode; } Tools.SnappingMode = SnappingMode.BoundingBox; IsOpened = !IsInPlayMode; PlaymodeStateChanged += OnPlaymodeStateChanged; IsOpenedChanged += OnIsOpenedChanged; Selection.SelectionChanged += OnRuntimeSelectionChanged; Tools.ToolChanged += OnRuntimeToolChanged; Tools.PivotRotationChanged += OnPivotRotationChanged; Undo.UndoCompleted += OnUndoCompleted; Undo.RedoCompleted += OnRedoCompleted; Undo.StateChanged += OnUndoRedoStateChanged; TransformPanel.SetActive(Selection.activeTransform != null); if (Prefabs != null && PrefabsPanel != null && PrefabPresenter != null) { Prefabs = Prefabs.Where(p => p != null).ToArray(); for (int i = 0; i < Prefabs.Length; ++i) { GameObject presenter = Instantiate(PrefabPresenter); presenter.transform.SetParent(PrefabsPanel.transform); presenter.transform.position = Vector3.zero; presenter.transform.localScale = Vector3.one; InstantiatePrefab instantiatePrefab = presenter.GetComponentInChildren <InstantiatePrefab>(); if (instantiatePrefab != null) { instantiatePrefab.Prefab = Prefabs[i]; } TakeSnapshot takeSnapshot = presenter.GetComponentInChildren <TakeSnapshot>(); if (takeSnapshot != null) { takeSnapshot.TargetPrefab = Prefabs[i]; } } } }
private void Awake() { Instance = this; 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; } RuntimeTools.SnappingMode = SnappingMode.BoundingBox; RuntimeEditorApplication.IsOpened = !IsInPlayMode; RuntimeEditorApplication.SceneCameras = new[] { EditorCamera }; RuntimeEditorApplication.PlaymodeStateChanged += OnPlaymodeStateChanged; RuntimeEditorApplication.IsOpenedChanged += OnIsOpenedChanged; RuntimeSelection.SelectionChanged += OnRuntimeSelectionChanged; RuntimeTools.ToolChanged += OnRuntimeToolChanged; RuntimeTools.PivotRotationChanged += OnPivotRotationChanged; RuntimeUndo.UndoCompleted += OnUndoCompleted; RuntimeUndo.RedoCompleted += OnRedoCompleted; RuntimeUndo.StateChanged += OnUndoRedoStateChanged; TransformPanel.SetActive(RuntimeSelection.activeTransform != null); if (Prefabs != null && PrefabsPanel != null && PrefabPresenter != null) { Prefabs = Prefabs.Where(p => p != null).ToArray(); for (int i = 0; i < Prefabs.Length; ++i) { GameObject presenter = Instantiate(PrefabPresenter); presenter.transform.SetParent(PrefabsPanel.transform); presenter.transform.position = Vector3.zero; presenter.transform.localScale = Vector3.one; InstantiatePrefab instantiatePrefab = presenter.GetComponentInChildren <InstantiatePrefab>(); if (instantiatePrefab != null) { instantiatePrefab.Prefab = Prefabs[i]; } TakeSnapshot takeSnapshot = presenter.GetComponentInChildren <TakeSnapshot>(); if (takeSnapshot != null) { takeSnapshot.TargetPrefab = Prefabs[i]; } } } }