Exemplo n.º 1
0
        public static GameObject Create()
        {
            GameObject    go            = new GameObject("Hero Block");
            HeroKitObject heroKitObject = go.AddComponent <HeroKitObject>();

            heroKitObject.heroObject = HeroKitCommon.AddHeroObjectToFolder(false);

            Camera  sceneCam = SceneView.lastActiveSceneView.camera;
            Vector3 spawnPos = sceneCam.ViewportToWorldPoint(new Vector3(0.5f, 0.1f, 2.5f));

            go.transform.position = spawnPos;
            return(go);
        }
Exemplo n.º 2
0
    /// <summary>
    /// Display a custom inspector for the hero kit object.
    /// </summary>
    public override void OnInspectorGUI()
    {
        HeroObject oldHeroObject = heroKitObject.heroObject;

        heroKitObject.heroObject = SimpleLayout.ObjectField("Hero Object", 100, heroKitObject.heroObject, 200, false);
        HeroObject newHeroObject = heroKitObject.heroObject;

        // has hero object changed? if yes, refresh graphics
        if (newHeroObject != oldHeroObject)
        {
            HeroKit.Scene.HeroKitCommonRuntime.RefreshVisuals(heroKitObject);
        }

        if (heroKitObject.heroObject == null)
        {
            SimpleLayout.BeginVertical(EditorStyles.helpBox);
            SimpleLayout.Label("Drag the hero object you want to use from the Project Tab into the field above. Or you can choose an existing hero object by selecting the icon to the right of the field above.\n\nIf you want to create a new hero object and assign it to this field, click the button below.", true);
            SimpleLayout.EndVertical();
            if (GUILayout.Button("Create & Assign Hero Object"))
            {
                heroKitObject.heroObject = HeroKitCommon.AddHeroObjectToFolder(false);
                Selection.activeObject   = heroKitObject.transform;
            }
        }

        else if (heroKitObject.heroObject != null)
        {
            if (GUILayout.Button("Edit Hero Object"))
            {
                HeroKitEditor.ButtonClickHeroObjectAsset(heroKitObject.heroObject);
            }

            if (GUILayout.Button("Show Details"))
            {
                ToggleDetails();
            }

            // show existing inspector
            if (showDetails)
            {
                base.OnInspectorGUI();
            }
        }
    }
Exemplo n.º 3
0
 public static HeroObject Create()
 {
     return(HeroKitCommon.AddHeroObjectToFolder(true));
 }