public string GenerateContent(BaseDriven ability)
        {
            BuildDriven   buildAbility = ability as BuildDriven;
            StringBuilder sb           = new StringBuilder("// This File is auto generated! Don't modify!!!\n");

            sb.AppendFormat("\"{0}\"\n", buildAbility.Name);
            sb.AppendLine("{");
            sb.AppendLine("\t\"Driven\"\t\"abilitydriven\"");

            sb.Append("}");
            return(sb.ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// 画驱动属性面板
        /// </summary>
        /// <param name="ability">驱动</param>
        public void OnGUI(BaseDriven ability, DataDrivenEditor dataDrivenEditor)
        {
            float WindowHeiht = dataDrivenEditor.position.height;
            float WindowWidth = dataDrivenEditor.position.width;

            if (buildAbility != ability)
            {
                buildAbility = ability as BuildDriven;
                GameObject obj = AssetDatabase.LoadAssetAtPath <GameObject>(ResPrePath + buildAbility.Model);
                gameObjectEditor = Editor.CreateEditor(obj);
            }
            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal();

            float h = EditorGUIUtility.singleLineHeight * 3;

            GUILayout.BeginArea(new Rect(0, h, 500, 500));
            if (gameObjectEditor != null)
            {
                gameObjectEditor.OnPreviewGUI(GUILayoutUtility.GetRect(500, 500), EditorStyles.whiteLabel);
            }
            else
            {
                EditorGUILayout.LabelField("模型加载失败");
            }
            GUILayout.EndArea();
            GUILayout.BeginArea(new Rect(500, h, WindowWidth - 500, WindowHeiht - h));

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
            EditorGUILayout.BeginVertical();
            // 展示所有的属性
            string newModel = EditorGUILayout.TextField("模型名称:", buildAbility.Model);

            if (newModel != buildAbility.Model)
            {
                GameObject obj = AssetDatabase.LoadAssetAtPath <GameObject>(ResPrePath + newModel);
                buildAbility.Model = newModel;
                gameObjectEditor   = Editor.CreateEditor(obj);
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();

            GUILayout.EndArea();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }