/// <summary> /// Sets the ID used for the name. /// </summary> /// <param name="value">GUID value to set.</param> public void SetFileGUID(GUID value) { if (value.Empty()) { value = GUID.Generate(); } m_GUID = value; }
protected void SwapMainWindow(Type type) { if (type.BaseType != typeof(PlayModeView)) { throw new ArgumentException("Type should derive from " + typeof(PlayModeView).Name); } if (type.Name != GetType().Name) { var serializedViews = ListsToDictionary(m_SerializedViewNames, m_SerializedViewValues); // Clear serialized views so they wouldn't be serialized again m_SerializedViewNames.Clear(); m_SerializedViewValues.Clear(); var guid = GUID.Generate(); var serializedViewPath = Path.GetFullPath(Path.Combine(m_ViewsCache, guid.ToString())); if (!Directory.Exists(m_ViewsCache)) { Directory.CreateDirectory(m_ViewsCache); } InternalEditorUtility.SaveToSerializedFileAndForget(new[] { this }, serializedViewPath, true); serializedViews.Add(GetTypeName(), serializedViewPath); PlayModeView window = null; if (serializedViews.ContainsKey(type.ToString())) { var path = serializedViews[type.ToString()]; serializedViews.Remove(type.ToString()); if (File.Exists(path)) { window = InternalEditorUtility.LoadSerializedFileAndForget(path)[0] as PlayModeView; File.Delete(path); } } if (!window) { window = CreateInstance(type) as PlayModeView; } window.autoRepaintOnSceneChange = true; window.SetSerializedViews(serializedViews); var da = m_Parent as DockArea; if (da) { da.AddTab(window); da.RemoveTab(this); DestroyImmediate(this, true); } } }
private void ValidateGUID() { if (this.m_GUID.Empty()) { this.m_GUID = new GUID(this.m_SpriteID); if (this.m_GUID.Empty()) { this.m_GUID = GUID.Generate(); this.m_SpriteID = this.m_GUID.ToString(); } } }
private void ValidateGUID() { if (m_GUID.Empty()) { // We can't use ISerializationCallbackReceiver because we will hit into Script serialization errors m_GUID = new GUID(m_SpriteID); if (m_GUID.Empty()) { m_GUID = GUID.Generate(); m_SpriteID = m_GUID.ToString(); } } }
void Awake() { m_HierarchyType = HierarchyType.GameObjects; if (string.IsNullOrEmpty(m_WindowGUID)) { m_WindowGUID = GUID.Generate().ToString(); } if (m_SceneHierarchy == null) { m_SceneHierarchy = new SceneHierarchy(); } m_SceneHierarchy.Awake(this); }